原github
原课程

条件查询

Pandas条件查询 apply
Pandas条件查询 apply
Pandas条件查询 apply
Pandas条件查询 apply
Pandas条件查询 apply

视频中8:27,他说,这个df是行的series,传入lambda,我感觉这里他说错了,还是df

Pandas条件查询 apply

df.apply方法

Apply a function along an axis of the DataFrame.

Objects passed to the function are Series objects whose index is either the DataFrame’s index (axis=0) or the DataFrame’s columns (axis=1).

实例:添加一列温度类型:

如果最高温度大于33度就是高温
低于-10度是低温
否则是常温
Pandas条件查询 apply
Pandas条件查询 apply

df.assign方法

Assign new columns to a DataFrame.
Returns a new object with all original columns in addition to new ones.
实例:将温度从摄氏度变成华氏度

Pandas条件查询 apply
这里可以参考下assign的API 不是很看得懂

相关文章:

  • 2021-05-29
  • 2022-12-23
  • 2021-08-05
  • 2021-07-13
猜你喜欢
  • 2022-01-25
  • 2022-12-23
  • 2021-12-18
  • 2022-12-23
  • 2021-12-09
  • 2021-06-05
相关资源
相似解决方案