0

Im new to Python Pandas, and was wondering if there was a way to join left two .csv files based on the column index number, at the moment i have this.

#Obtaining first csv files
neutral = pd.read_csv('neutral.csv')
meter = pd.read_csv('meter.csv')
#Left joins on MSN them to create merged Dataframe
merged = pd.merge(ph_neutral, meter,
                   on='MSN',
                   how='left')

but instead of joining on 'MSN' i want to join on the column index 1

gitmcgee
  • 141
  • 1
  • 1
  • 15
  • 1
    replace `on='MSN'` with `left_on=ph_neutral.columns[1], right_on=meter.columns[1]`. – Quang Hoang Dec 12 '21 at 20:25
  • Please provide some sample data and your desired output. (See [How to make good reproducible pandas examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples). – RoseGod Dec 12 '21 at 20:36
  • Try to run something like this: ph_neutral.merge(meter, left_index=True, right_index=True, how='left') – Alexander Martins Dec 13 '21 at 12:39

0 Answers0