Menu

Pandas for Beginners: Data Analysis in Python Without the Headaches
📰

Pandas for Beginners: Data Analysis in Python Without the Headaches

DEV Community: datascience·Arhan Khan·about 18 hours ago
#tkkfVE5R
#devtodatascience#science#devto#dev#python
Long article (356 words) — no AI summary yet.
Reading 0:00
15s threshold

If you work with data in Python, you will meet Pandas — the library that turns messy spreadsheets and CSV files into something you can actually analyze. Its core object is the DataFrame: a table with named columns that you can filter, sort, group, and summarize in a few lines.

Start with a CSV file:

import pandas as pd

df = pd . read_csv ( "sales.csv" )

print ( df . head ( ) ) # first 5 rows print ( df . describe ( ) ) # summary stats for numeric columns print ( df . shape ) # (rows, columns)

Enter fullscreen mode

Exit fullscreen mode

Filtering is where it starts to feel like magic:

# All orders over 1000 rupees from Mumbai big_mumbai = df [ ( df [ "amount" ] > 1000 ) & ( df [ "city" ] == "Mumbai" ) ]

# Total sales per city, sorted print ( df . groupby ( "city" ) [ "amount" ] . sum ( ) . sort_values ( ascending = False ) )

# Monthly average, if you have a date column df [ "month" ] = pd . to_datetime ( df [ "date" ] ) . dt . to_period ( "M" ) print ( df . groupby ( "month" ) [ "amount" ] .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.