Data ScienceIntermediate

Data Analysis with Pandas in Python

Learn Pandas for data analysis in Python! A beginner-friendly guide to DataFrames, filtering data, grouping, and handling messy missing data just like Excel.

Try it yourself

Run this code directly in your browser. Click "Open in full editor" to experiment further.

Loading...

Click Run to see output

Or press Ctrl + Enter

How it works

Pandas is the absolute king of Python data analysis! If you've ever used Excel or Google Sheets, you already know how to use Pandas—you just don't know the code yet! 🐼

The Pandas Dictionary

1. Series: Think of this as a single column in a spreadsheet.

2. DataFrame: This is your entire spreadsheet! It has multiple columns, and each column can be a different type of data (like names, ages, and salaries).

Awesome Things We Can Do

  • Instant Statistics: With just df.describe(), Pandas instantly does all the math to tell you the average, minimum, maximum, and percentiles for every single numeric column in your dataset. It's magic!
  • Filtering (Boolean Indexing): Want to find everyone older than 28? Just write df[df['Age'] > 28]. It's that easy! You can even chain conditions using & (AND) or | (OR).
  • Group By: This is just like a Pivot Table. groupby() lets you quickly categorize your data. Want to know the average salary in each city? Group by City, select the Salary column, and ask for the mean()!
  • Cleaning Messy Data: Real-world data is awful. Sometimes people forget to fill out forms or sensors break! Pandas can easily spot these blanks (NaNs - Not a Number) and fill them in with an average, or drop them entirely using fillna() or dropna().
  • Run the code to see a virtual spreadsheet come to life and crunch some serious numbers!

    Related examples

    Keywords: python pandas tutorial, pandas dataframe operations, python data analysis, pandas groupby tutorial, data science python pandas, pandas filtering data