pandas替换筛选关联
规则 df.replace(‘old’,new)
要改变源数据需要使用inplace = True,不这样的操作并没有改变文档的源数据。
1.部分替换
df['Row Labels'] = df['Row Labels'].str.replace('/','')
2.取前n位数据
df['Labels'] = df['Row Labels'].apply(lambda x:x[:n]).tolist()
3.列表数据判断
import pandas as pd
import numpy as np
df
原创
2021-11-16 15:50:24 ·
1095 阅读 ·
0 评论