Picking columns, rows in Pandas

Picking columns, rows in Pandas

Note: To identify a specific cell, it’s good to have at least a unique id column to reference.

This part grabs the specific row: df.loc[df['id'] == number]

This part grabs the specific column: ['column_name']

# generic
df.loc[df['id'] == number]['column_name']

# specific
concat_frames_4.loc[concat_frames_4['id'] == 1983]['choice']

For more content on Data and DAOs find me on Twitter.

Previous
Next