Articles

Python Pandas for Business Analysts: The 10 Functions You Actually Need

Pandas is the Python library for working with tabular data - the kind of data that lives in spreadsheets, databases, and CSV exports. If you understand Excel, you can learn pandas. The ten functions below cover 90 percent of what business analysts actually need.

1. read_csv and read_excel

These load data from files. pd.read_csv('file.csv') and pd.read_excel('file.xlsx'). Both handle a wide range of file formats and encoding issues with optional parameters.

2. head and tail

df.head(10) shows the first 10 rows. df.tail(10) shows the last 10. Use these constantly to verify your data looks as expected after any transformation.

3. shape and dtypes

df.shape returns the number of rows and columns. df.dtypes shows the data type of each column. These two properties catch most data loading issues immediately.

4. filtering with boolean conditions

df[df['revenue'] > 100000] filters rows where revenue exceeds 100,000. Chain conditions with & for AND and | for OR. This replaces Excel filters.

5. groupby and agg

df.groupby('region')['revenue'].sum() calculates total revenue by region. Replace sum with mean, count, max, min, or pass multiple aggregations with agg. This replaces pivot tables.

6. merge

pd.merge(df1, df2, on='customer_id') joins two dataframes on a common column. Supports left, right, inner, and outer joins. This replaces VLOOKUP.

7. fillna and dropna

df.fillna(0) replaces null values with zero. df.dropna() removes rows with any null values. Data quality handling belongs here before any calculation.

8. apply

df['category'].apply(lambda x: 'Large' if x > 1000 else 'Small') applies a function to every value in a column. This replaces nested IF formulas.

9. sort_values

df.sort_values('revenue', ascending=False) sorts the dataframe. Add multiple columns in a list to sort by more than one field.

10. to_csv and to_excel

df.to_csv('output.csv', index=False) and df.to_excel('output.xlsx', index=False) write the result to a file. The index=False parameter prevents pandas from adding an unnecessary row number column.


If you want to take your team from Excel to Python for reporting automation, reach out. We run workshops and build the tooling that makes the transition practical.

Have a question about this topic? We work with businesses worldwide.

Get in Touch