“Pandy, gdzie oparte na innej kolumnie” Kod odpowiedzi

Pandy, gdzie oparte na innej kolumnie

# Changes the 'is_electric' column based on value in the 'type' column
# If the 'type' column == 'electric' then the 'is_electric' becomes 'YES'
df['is_electric']= df['type'].apply(lambda x: 'YES' if (x == 'electric') else 'NO') 
Trained Tuna

Kolumna Pandas DataFrame oparta na innej kolumnie

df['c2'] = np.where(df.c1 == 8,'T', 'F')

   c1  c2  c3
0   4   F   1
1   8   T   9
2   1   F   8
3   3   F   5
4   3   F   8
Arno Deceuninck

Odpowiedzi podobne do “Pandy, gdzie oparte na innej kolumnie”

Pytania podobne do “Pandy, gdzie oparte na innej kolumnie”

Więcej pokrewnych odpowiedzi na “Pandy, gdzie oparte na innej kolumnie” w Python

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu