Here's one method:
import pandas as pd
d1 = pd.DataFrame({'Airline':['A','B','C'],'Delays':[[],[1],[1,2]]})
# Expand column into temporary Dataframe
d2 = d1['Delays'].apply(pd.Series)
# Integrate temp columns back into original Dataframe (while naming column)
for col in d2:
d1["Delay%d" % (col+1)] = d2[col]
print(d1)
Before:
Airline Delays
0 A []
1 B [1]
2 C [1, 2]
After:
Airline Delays Delay1 Delay2
0 A [] NaN NaN
1 B [1] 1.0 NaN
2 C [1, 2] 1.0 2.0
You could also name the columns in the temp dataframe with:
# Name columns of new dataframe
d2.columns = ["Delay%d" % (i+1) for i in range(len(d2.columns))]
And then use concat.
You can also drop the now-expanded Delays column with something like:
d1.drop(columns=['Delays'], inplace=True) # or,
d1.drop(['Delays'], axis=1, inplace=True)