(float) # 将Series中的数据类型更改为float类型
s.replace(1,'one') # ⽤‘one’代替所有等于1的值
s.replace([1,3],['one','three...']) # ⽤'one'代替1,⽤'three'代替3
df.rename(columns=lambdax:x+1) # 批量更改列名
df.rename(columns={'old_name':'...(np.max,axis=1) # 对DataFrame中的每⼀⾏应⽤函数np.max
df.groupby(col1).col2.transform("sum") # 通常与groupby连⽤,避免索引更改...(10)]
squares
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
同时还可以利用if来过滤列表
[(x, y) for x in [1,2,3] for y in [...(lambda x, y: x+y, [1,2,3,4,5]) # 使用 lambda 匿名函数
print(sum1)
print(sum2)
15
15
字典.get()方法
D.get(key[