DATA100-L4: Pandas Ⅱ
Contents
lambda function
|
|
非显式定义函数,可以直接使用lambda表达式来定义一个函数。
This is a lambda function that takes in one argument x and returns the square of x.
再看sort_values()
注意传递key
|
|
add move modify and so on
sort by length of string
- approach1: create a new column and add to original df
|
|
drop column

groupby.agg
never use loops in this class!

|
|
- f is a dictionary of functions to apply to each column.
- The function can be a lambda function or a named function.
groupby
type: pandas.core.groupby.generic.DataFrameGroupBy
filter
|
|
- This will return a new DataFrame with only the groups that have a mean value greater than 10.

multi index 多维索引
using pivot_table()
|
|
- This will create a multi-index pivot table with the specified index and columns, and the mean of column4 for each group.
using groupby()
|
|
- This will group the DataFrame by column1 and column2, and calculate the mean and sum of column3 and column4 for each group.
joining tables
|
|
