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" ] .…