I have the following lists in python created by reading files
files_list = ["A", "B", "C", "D"]
The contents of the files are character vectors as follows
A = ["A1"]
B = ["A2", "B1"]
C = ["A3", "B3", "C3", "C3"]
D = []
I would like to create the following dataframe
Col1 Col2
A A1
B A2, B1
C A3, B3, C3
D
The filenames should be rendered as one column and the second column should contain the content of the files as a single line.
I tried the following code using a for loop. Note that this is a toy dataset and my dataset is a bit larger
import pandas as pd
df3 = pd.DataFrame()
for i in list_name:
for j in i:
df3["Col1"] = j
df3["Col2"] = i
How do i accomplish the same using the for loop I request someone to take a look. The df3 object i generated was empty