Stage 1 · Lesson 5 of 9
pandas DataFrames: selecting, filtering and cleaning
A is a table. Each column has a name and holds one type of data, and a single column on its own is called a Series. An index the rows.
Most real data work happens here. Learn to load a file with read_csv and look around with head, info, describe and value_counts. Then select columns, and keep only matching rows with a condition such as df[df['age'] > 30].
Use .loc to select by label and .iloc to select by position. Create new columns from existing ones, and fix types with astype and to_datetime. Vectorisation still applies: df['total'] = df['price'] * df['qty'] beats looping with iterrows every time.
Common trap like df[df.x > 0]['y'] = 1. It may change a temporary copy rather than df, so write df.loc[mask, 'y'] = 1 instead.
A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock
Resources for this stage
Start with· follow one of these
- CoursePaidGrokking Python Fundamentals
Design Gurus · Beginner · $50
Core Python with an exercise after nearly every lesson, before the data libraries
- BookFreePython for Data Analysis, 3rd Edition
Wes McKinney · Beginner
Free online: NumPy, pandas and plotting from pandas' own creator