How to append a list to pandas column, series? How to append a list to pandas column, series? pandas pandas

How to append a list to pandas column, series?


just copy the same format you used (dict) to make a dataframe like so:

import pandas as pdd = {'col1': [1, 2], 'col2': [3, 4]}df = pd.DataFrame(data=d)xtra = {'col1': [3,4]}df = df.append(pd.DataFrame(xtra))


Use pd.DataFrame and DataFrame.append:

df = df.append(pd.DataFrame(xtra, columns=['col1']), ignore_index=True)print(df)  col1  col20     1   3.01     2   4.02     3   NaN3     4   NaN


You can also add those rows without creating annother Dataframe by iterating on xtra:

for val in xtra:    df = df.append({'col1' : val}, ignore_index=True)