Home > Software engineering >  Replacin values of a pandas column
Replacin values of a pandas column

Time:10-29

I have the following dataframe:

col1
01
1
02
2
03
3
00
0

How can I replace values in col1 to be like the expected output below:

Expected Output:

col1
1
1
2
2
3
3
0
0

CodePudding user response:

Can you try this?

df['col1']=[int(x) for x in df['col1']]

CodePudding user response:

You can do it like this:

df['col1'] = df['col1'].astype('int')
  • Related