Pandas Notes

DataFrame Query Method


  1. df.query("name==ok")
  2. df[].count()

// Return a slice copy of the DataFrame based on condition
// indexing operators [] and attribute operator .


  1. series.where(id==3)

Returning a VIew v.s. Copy

  1. Return a copy : df[0]["ccc"] // this is chain indexing
  2. Return a view: df.loc[0, "ccc"]

DataFrame Apply Function

  1. df.apply() can apply specified operation on the dataframe object

Added a new column to the DataFrame based existing columns

  1. df = df.apply()
  2. df = df["one_column"].apply()