Pandas 某一列数据小数点转换:
df_train['万元平'] = df_train['万元平'].apply(lambda x: '%.2f' % x)
Pandas 某一行进行判断操作
df_c = df[df.apply(lambda row: (row['avg_price'] != row['万元平']) & (row['万元平'] > 0), axis=1)]
操作某一行数据并返回满足条件的行
def contain_ids(row):
if row['id'] in [1318, 1278, 1196, 1177, 1289, 1104, 1189, 1134, 1140]:
return True
else:
return False
df[df.apply(contain_ids, axis=1)]
网友评论