I’m new to python and struck in a problem.
df1 = pd.DataFrame({'col1': ['apple', 'banana', 'cherry', 'apple', 'cherry']})
df2 = pd.DataFrame({'col1': ['app Banana', 'Cherry', 'banana', 'apple', 'bnapple', 'apple ch']})
Suppose I have df2 and df1 which have col1 values. df1 has correct full names but may have duplicates (which I need to keep in both dataframes due to other col data being different).
df2 has either bad names or incorrect case, which I want to correct. I want df2 column to reflect what df1 col says. the resulting column for df2 would be –
df2 = pd.DataFrame({'col1': ['banana', 'cherry', 'banana', 'apple', 'apple', 'apple']})
TIA!
I don’t know how to. I tried merge query of dataframe but that just gave out everything in df1 + df2.
Kush is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.