• pd.read_csv: read data from csv

Overview

  • df.head(): first few data
  • df.info(): how many entries, what are the columns, dtypes
  • df.describe(): some statistics of each column
  • df.shape: shape
  • df.value_counts(): amount of data for each value in a column

Select

  • iloc[] selects by integer position
  • loc[] selects by label
  • df.isna() finds N/A
mask = (penguins["body_mass_g"] > 5000) & (penguins["flipper_length_mm"] > 220)
penguins[mask].head()
  • df.dropna(): drop rows includes N/A

Grouping

  • df.groupby(): group data by the value in a column
df.groupby("species")[["bill_length_mm", "flipper_length_mm", "body_mass_g"]].mean().round(1)

Numpy

  • df.to_numpy() turns a Dataframe to a numpy array.