Home Up PDF Prof. Dr. Ingo Claßen
Pandas Introduction - DSML

Dataframe Creation

  • create a pandas dataframe df_customer for customer data with 6 rows and columns lastname, birthdate, city, total_revenue. city should only contain "New York", two times and "Washington", 4 times
  • explain the generated code
  • show info of dataframe
  • show statistical summary of dataframe

Columns

  • generate examples for accessing columns
  • explain the generated code

Rows

  • generate examples for accessing rows
  • explain difference between loc and iloc
  • explain indexes
  • create a new column called id that combines the first 3 letters of lastname then a hyphon followed by year of birthdate
  • use column id as index

Filtering and Aggregation of Rows

  • filter rows by city "New York"
  • explain the generated code
  • calculate sum of total_revenue and average age of customers per city