I am trying to merge two or more csv files so that
MetaData1
Sample_name TITLE
Cody Chicken Pox
Claudia Chicken Pox
Alex Chicken Pox
Steven Chicken Pox
Mom Chicken Pox
Dad
MetaData2
Sample_name TITLE Geo_Loc DESCRIPTION
Dad Chicken Pox Earth people
Me Chicken Pox Earth people
Roger Chicken Pox Earth people
Ben Chicken Pox Earth people
Merge together to look like this:
Merged Metadata
Sample_name TITLE Geo_Loc DESCRIPTION
Cody Chicken Pox Missing:Not Applicable Missing:Not Applicable
Claudia Chicken Pox Missing:Not Applicable Missing:Not Applicable
Alex Chicken Pox Missing:Not Applicable Missing:Not Applicable
Steven Chicken Pox Missing:Not Applicable Missing:Not Applicable
Mom Chicken Pox Missing:Not Applicable Missing:Not Applicable
Dad Chicken Pox Earth people
Me Chicken Pox Earth people
Roger Chicken Pox Earth people
Ben Chicken Pox Earth people
The code I have so far is Below: However its only stitching the two csv files together not really amending and over laying. as the images above.
import pandas as panda
import numpy as numpy
File_one = panda.read_csv('/Users/c1carpenter/Desktop/Test.txt', sep='\t', header=0, dtype=str)
File_two = panda.read_csv('/Users/c1carpenter/Desktop/Test2.txt', sep='\t', header=0, dtype=str)
Concat_File = panda.concat([File_one, File_two])
for column_header in Final_File:
for entry in Final_File[column_header]:
if str(entry) == 'nan':
print(entry)
entry = 'not applicable'
print("changed to: " + entry)
Concat_File.to_csv(path_or_buf='/Users/c1carpenter/Desktop/' + 'diditwork.txt', sep='\t', na_rep='not applicable',index=False)