Answers for "convert pandas list in column to columns"

8

python - convert a column in a dataframe into a list

myvar_list = df["myvar"].tolist()
Posted by: Guest on September-01-2020
0

python - convert a list column into miltiple columns

# Method 1
df[['team1','team2']] = pd.DataFrame(df.column_with_list.tolist(), index= df.index)

# Method 2
df['team1'], df['team2'] = list(zip(*((x[0], x[1]) for x in df['column_with_list'].values)))
Posted by: Guest on December-17-2020

Code answers related to "convert pandas list in column to columns"

Python Answers by Framework

Browse Popular Code Answers by Language