Skip to content Skip to sidebar Skip to footer

Append Series To Dict Or List Or Dataframe From For Loop?

I have created a for loop which gives an out like this: SSTIME SCODE 0 0 1 57 3 202 I did reset_index on this series and i got this: S

Solution 1:

I think you need not reset_index, but concat of list of Series:

list_ser = []
#sample loop for crate Series
for x in L:
    s = create_function()
    list_ser.append(s)

df = pd.concat(list_ser)

Solution 2:

You can convert each of these dataframes to a dictionary with pandas.DataFrame.to_dict()

And afterwards add to a list:

result = []
for x in range(1,13):
    result.append(x)

Post a Comment for "Append Series To Dict Or List Or Dataframe From For Loop?"