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

Class 12 Data Handling using Pandas – I: cheat sheet

CBSE Informatics Practices. pandas Series and DataFrames: making them, selecting with loc and iloc, filtering, changing and saving them.

Open the printable cheat sheetPractice worksheet

Key ideas

Remember

Labels a to fs.loc['b':'d'] → b, c, d; s.iloc[1:3] → b, c
Some columnsdf[['Name', 'Maths']] (two pairs of brackets)
shape (r, c), size r × cadd a column: c + 1; drop a row: r − 1; drop a column: c − 1

Watch out

Worked example

Series s: a | 38 b | 96 c | 75 d | 29 e | 61 f | 56 Write the output of each statement, and say why they differ. (a) print(s.loc['b':'f']) (b) print(s.iloc[1:5])

Working: loc slices by label (end included); iloc by position (end left out)

Answer: (a) b | 96 c | 75 d | 29 e | 61 f | 56 (b) b | 96 c | 75 d | 29 e | 61 loc includes the end label f; iloc stops before position 5.

Practise Data Handling using Pandas – I

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

Coming soon for Android and iPhone.