I need to create a Dataframe after iterating through a nested list. I have 6 values that I would like mapped to a column in a Dataframe
You could use list of dicts to create DataFrame
.
Store dict for every needed row and create DataFrame
from stored rows:
import pandas as pd
frame_rows = [] # List to store dicts
for x in message:
if len(x[15][0][0][0]) == 0:
row_data = {
'a': x[72][0],
'b': x[15][0],
'c': x[17][0],
'd': x[19][0],
'e': x[73][0],
'f': x[71][0],
}
frame_rows.append(row_data)
df = pd.DataFrame(frame_rows) # Create dataframe
print(df.head())