0

I try to append below 2 files' data. But the column "ytd" is appended in different column. And the columns reorder by alphabet. Would appreciate some guidance on how to keep the columns order as the original file and make the ytd column of the 2 files together. Many thanks

My code is as below:

dfaq=pd.read_csv('aq2.csv')
dfmg1=pd.read_csv('test10320_2.csv')
dfaq1=dfmg1.append(dfaq, ignore_index=True)

aq.csv enter image description here

mg10320.csv enter image description here

** incorrect Result** enter image description here

jun
  • 21
  • 2
  • It sounds like you want to [merge](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.merge.html) the two dataframes on the `ytd` column. – Jan Wilamowski Nov 04 '21 at 08:40
  • Does this answer your question? [Pandas Merging 101](https://stackoverflow.com/questions/53645882/pandas-merging-101) – Jan Wilamowski Nov 04 '21 at 08:41

0 Answers0