Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pandas explode

	Product			Cost	Tags
0	RAM	    		100		Add-on,Electronics
1	Laptop			5000	Units,Electronics
2	Rubber Ducky	50		Units,Decoration
# above into below
	Tags		Cost
	Add-on		100
	Electronics	5100
	Units		5050
	Decoration	50
# code -->
df['Tags'] = df['Tags'].str.split(',')
df = df.explode('Tags') 
data.groupby('Tags').sum()
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pandas #explode
ADD COMMENT
Topic
Name
4+7 =