Pandas 某一列數(shù)據(jù)小數(shù)點轉(zhuǎn)換:
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)]
操作某一行數(shù)據(jù)并返回滿足條件的行
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)]