Worksheets › Class 12 › Data Handling using Pandas – II › Cheat sheet

Class 12 Data Handling using Pandas – II: cheat sheet

CBSE Informatics Practices. Analysing data with pandas: descriptive statistics, sorting, groupby, missing values with count, isnull, dropna and fillna, and moving data between pandas and MySQL.

Open the printable cheat sheetPractice worksheet

Key ideas

Remember

mean()total ÷ number of values present: (74 + 25 + 21 + 60 + 45) ÷ 5 = 45.0
dropna().shape(rows with no missing value, the same number of columns)
fillna(0).sum()the same total as sum(), printed as a float
groupbydf.groupby('Store')['Price'].max(); adding ['North'] picks one group
Range of a columndf['Marks'].max() - df['Marks'].min()
describe()count, mean, std, min, quartiles and max of each numeric column

Watch out

Worked example

DataFrame df: index | Item | Store | Price | Stock P1 | Eraser | South | — | 90 P2 | Diary | North | 74 | 50 P3 | Pen | East | 25 | 27 P4 | Notebook | East | 21 | 56 P5 | Folder | East | 60 | 72 P6 | Crayons | North | 45 | 75 (— marks a missing value; pandas prints it as Not a Number.) Write the output of: (a) print(df['Price'].count()) (b) print(df['Price'].sum()) (c) print(df.dropna().shape)

Working: (a) and (b) skip missing values, and the column is a float column; (c) drops the rows with a missing value

Answer: (a) 5; (b) 225.0; (c) (5, 4)

Practise Data Handling using Pandas – II

Revise with this page, then practise: every Data Handling using Pandas – II sheet in the app is new, with an answer key and working.

Coming soon for Android and iPhone.