I have a pandas dataframe: df:
id name
1 abc
I do:
df['name'] = df['name'].str.upper()
I get a duplicate row:
id name
1 ABC
nan ABC
What is going on?
I have a pandas dataframe: df:
id name
1 abc
I do:
df['name'] = df['name'].str.upper()
I get a duplicate row:
id name
1 ABC
nan ABC
What is going on?
The problem is that the observed issue is not reproducible in an isolated code example. What is shown in the question indicates that the procedural code is correct. Therefore, there is a problem with input data that is not depicted.
This following MCVE (How to make good reproducible pandas examples) shows that there is no problem:
import pandas as pd
df = pd.DataFrame({'id':[1], 'name': ['abc']})
print df
df['name'] = df['name'].str.upper()
print df
python mcve.py
id name
0 1 abc
id name
0 1 ABC
The example above shows an input DataFrame of
id name
1 abc
Which maybe is not a DataFrame?