0
df.Transmission.unique()

array(['Manual', 'DL9C', 'Automatic', 'DL5C', 'HR26', 'DL10', 'HR87',
   'HR29', 'UP16', 'DL6C', 'DL1C', 'DL2C', 'KA04', 'KA01', 'KA05',
   'KA02', 'KA41', 'KA51', 'KA53', 'KA50', 'KA03', 'KA22', 'KA09',
   'MH05', 'MH46', 'MH48', 'MH43', 'MH01', 'MH47', 'MH03', 'MH04',
   'MH02'], dtype=object)

df['InsuranceType'].unique()

array(['Third Party insurance', 'Manual', 'Not Available', 'Automatic',
   'Third Party'], dtype=object)

I want to swap these two column values at particular location. I m confused to how to do this

I tried to replace the values using

if df[(df['Transmission'] != 'Manual') | (df['Transmission'] != 'Automatic')]:
    df['Transmission'] = 'Manual'

Manual being the mode of the column.

But No Luck it didnt work

Sinchana
  • 11
  • 3
  • check this out https://stackoverflow.com/questions/31511997/pandas-dataframe-replace-all-values-in-a-column-based-on-condition/31512025 – Raymond Kwok Jan 26 '22 at 16:38

1 Answers1

0

I didn't understood fully what you want.

But we have a method call replace.

df.replace({old_value:new_value})

Where you can create a dictionary of values that you want to replace.

Victor_cbr
  • 21
  • 5