Find & Replace Equivalent with Pandas

Python
Data Preprocessing

In this example we replace each value 1 with 'A' and 2 with 'B' in the id column.

 1|  df.loc[df['id'] == 1, 'id'] = 'A'
 2|  df.loc[df['id'] == 2, 'id'] = 'B'
1 Upvote
Tags: Pandas | Loc
Did you find this snippet useful?

Sign up to bookmark this in your snippet library

Normalize Windowed Time Series
Python
Data Preprocessing

Scaler | Normalize | Scale | Min-max

4
Pivoting Pandas Dataframes
Python
Data Preprocessing

Pandas

3