0

Expected ResultActual Result3Firstly Both the columns are different with different data. Gathering these columns data from 2 different sheets and adding those collected columns in a new excel sheet. While writing to an excel sheet i can see BLANK cells.Below is the sample o/p i got. Table Please Find the attached snippet for reference (Actual & Expected Results)

import pandas as pd

data1 = pd.read_csv(r'File1.dat', sep='|')
df1 = data1.loc[:, ['Sheet1_Col1']].drop_duplicates()


data2 = pd.read_excel(r'File2.xlsx')
df2= data2[data2['Sheet2_Col2'] == 'Number'].loc[:,'SOURCE_CODE'].drop_duplicates()

df_all_rows = pd.concat([df1,df2], axis=1)

after_concat = df_all_rows.to_excel('New_Sheet.xlsx',  sheet_name='Collected_columns', index=False)

Expected Result is columns collected from 2 different excel sheets should be able to add these collected data in a new excel sheet

  • This would be simpler to answer if you provide a sample of your data so we can reproduce and test. – Valentino Jun 15 '19 at 12:29
  • Please find the below sample data: Col1 Col2 Work E-Mail Personal Business FAX MOBILE MOBILE_PHONE PHONE WORK Personal Business Mobile Phone -NONE- – Anil Kumar S Jun 15 '19 at 14:34
  • Better to add it in the question, so you can format it properly. Click the [edit](https://stackoverflow.com/posts/56609583/edit) button. See [here](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) too. – Valentino Jun 15 '19 at 14:47
  • Hi Valentino,I've attached a snippet for your reference. Actual Result, Expcted Result & Sample data (Table). Please provide your valuable feedback. I'm stuck now. – Anil Kumar S Jun 16 '19 at 10:05

0 Answers0