Part V — The Modern Experience Layer · Chapter 29 · Lesson 1 of 2
Profiling, cleaning, joining and reshaping
std.analysis turns PeaLang into a capable data workbench: load, clean, transform, aggregate, export — no notebooks, no external services. Everything is functions over record lists.
Load and inspect
import analysis
let df = analysis.from_csv("orders.csv")
print df.shape # [rows, cols]
print analysis.profile(df) # nulls, cardinality, min/max/mean per column
profile gives you the null map, distinct counts and distribution summary in one call — the ten-minute first look you should do before any transformation.
Clean
clean_missing(df)/fillna(df, col, value)/impute(df, col, method)— handle nulls deliberately.dropnaandffill/bfillfor series data.drop_duplicates(df)/duplicated(df)— exact duplicates; for fuzzy dedup, finish withwinsorize/clipon the value columns.cast/astype— declare column types at load time when inference guessed wrong (dates are the usual suspect).
Transform
let paid = analysis.filter_rows(df, "status == 'paid'")
let by_city = analysis.group_by(paid, "city", { "revenue": "sum", "orders": "count" })
let ranked = analysis.sort_by(by_city, "revenue", "desc")
select / drop_columns / rename / add_column / assign shape columns; melt and transpose reshape; pivot / pivot_wider / pivot_table spread; join/merge and concat combine. Aggregation functions (mean_col / sum_col / median_col / mode / nunique) compose inside group_by.
Exploring
head / tail / sample / nlargest / nsmallest / unique / value_counts / top_values answer the usual questions in seconds. describe and corr_matrix/correlation surface relationships; quantile and histogram show the distribution shape.
Window operations
rolling_mean / rolling_std / expanding_mean / ewm_mean / pct_change / diff / shift / lag / lead / rank / cumsum — the time-series verbs from the DataFrame chapter, available as functions on records. date_range and calendar_features generate the frame itself.
Export
analysis.to_csv(by_city, "revenue-by-city.csv")
analysis.to_markdown(by_city) # for a PR description or report
analysis.to_html(by_city) # standalone table
Guided practice
- Take any CSV you have lying around; load,
profile, fix two columns' types, export. - Compute revenue by city and export the result as markdown; paste it into a memo.
- Join orders and customers on customer_id; verify row counts before and after.