Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to fix columns name of dataframe auto change after use merge or join?

i am using python 3.8, after use join or merge, my dataframe columns auto changes to (column name,) How could i fix it? i tried to use join, merge, and concat but it return the same result :((

here is some images about it

df_temp
enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

df_us_ed_songs_pos[0]

enter image description here

both of them have save index is Date. after i use join, it become like this

df_temp.join(df_us_ed_songs_pos[0])

enter image description here

all name columns of df_temp has changed. Anyone know how to fix it? thanks

update:
columns name:
enter image description here
enter image description here
enter image description here

hmmm, now i can see that df_temp columns seem wrong, but i checked name_us_ed_songs and it seem normal?

>Solution :

You could update the column names by using a list comprehension and taking off first and last char, like this:

df_temp.columns = [col[1:-1] for col in df_temp.columns]
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading