I'm trying to import other dataframe columns from various files into one file.
Let's say df1, df2 and df3 are each in different .py files but the files are saved in the same folder.
ie df1 is saved in df1.py df2 is saved in df2.py df3 is saved in df3.py
I am trying to figure out how to import a column from df2 and df3 into df1 (which has 7 rows) even though all dataframes have different number of rows.
NaN rows should be represented as a - (ie a dash '-')
df1 = pd.DataFrame()
df1['A'] = (1,22,13,41,2,56,79)
df1['B'] = ('B','S','S', 'S', 'S', 'B', 'B')
df1['C'] = (1.02, 1.01, 1.44, 1.05, 1.05, 1.12, 1.22)
df2 = pd.DataFrame()
df2['D'] = (11,65,8,34,56,18,91,34,89,35,3,9,15)
df2['E'] = ('E','R','Y', 'N', 'X', 'T','Y', 'N', 'X', 'T', 'D', 'T', 'D')
df2['F'] = (1.02, 1.01, 1.44, 1.05,1.02, 1.01, 1.44, 1.05, 1.05, 1.12, 1.22, 1.12, 1.22)
df3 = pd.DataFrame()
df3['G'] = (1,22,13)
df3['H'] = ('S','S', 'S')
df3['I'] = (1.05, 1.05, 1.12)
print the below is how I would like df1 to look after importing
df1 = pd.DataFrame()
df1['A'] = (1,22,13,41,2,56,79)
df1['B'] = ('B','S','S', 'S', 'S', 'B', 'B')
df1['C'] = (1.02, 1.01, 1.44, 1.05, 1.05, 1.12, 1.22)
df1['D'] = (11,65,8,34,56,18,91)
df1['E'] = ('E','R','Y', 'N', 'X', 'T','Y')
df1['F'] = (1.02, 1.01, 1.44, 1.05,1.02, 1.01, 1.44)
df1['G'] = (1,22,13, '-', '-', '-', '-')
df1['H'] = ('S','S', 'S', '-', '-', '-', '-')
df1['I'] = (1.05, 1.05, 1.12, '-', '-', '-', '-')
print(df1)
NaN
to a dash-
. Is that correct? – Erfan