columns= ['A','B','C']
df= pd.DataFrame(columns=columns)
I have a empty dataframe like above with named column header and I have files where each file has data like A 32, B 43 , C 21 and so on. I want to fill the dataframe in such a way that each file takes up one row and adds the data in each file in the respective column headers.
example-
let there be two files like-
file1 file2
A 32 A 56
B 31 B 34
C 45 C 12
then dataframe will be
'A' 'B' 'C'
32 31 45
56 34 12
edit-
for root, dirs, files in os.walk(dir_M):
for name in files:
L = [pd.read_csv(f, index_col=[0], header=None, sep='\s+')[1] for f in files]
df = pd.concat(L, axis=1).T