Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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)))
Comment

PREVIOUS NEXT
Code Example
Python :: clear many to many django 
Python :: set remove in python 
Python :: convert series to dataframe pandas 
Python :: opening a file in python 
Python :: explain the use of return keyword python 
Python :: model checkpoint 
Python :: how to code a funtion in python 
Python :: from a list of lists - find all length of list 
Python :: graph skewness detection 
Python :: docstring in python 
Python :: add legend to colorbar 
Python :: how to convert str to int python 
Python :: python catch print 
Python :: convert exception to string python 
Python :: check if value is in series pandas 
Python :: loops in python 
Python :: list insert python 
Python :: Replace an item in a python list 
Python :: sum up list python 
Python :: print() function in python 
Python :: 3d data visualization python 
Python :: django-filter for multiple values parameter 
Python :: truncatechars django 
Python :: cache-control no cache django 
Python :: django 3.2 compatible to python 3.10? 
Python :: python environment variable 
Python :: what does abs do in python 
Python :: Yield Expressions in python 
Python :: python and pdf 
Python :: float field vs decimal field in django models 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =