Machen Sie eine Bedingungsanweisung zu Spalten Pandas
df['color'] = ['red' if x == 'Z' else 'green' for x in df['Set']]
Fragile Finch
df['color'] = ['red' if x == 'Z' else 'green' for x in df['Set']]
df.loc[df['column name'] condition, 'new column name'] = 'value if condition is met'
df.loc[df['age1'] - df['age2'] > 0, 'diff'] = df['age1'] - df['age2']