Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python extract values that have different values in a column

df = pd.DataFrame({'author':['a', 'a', 'b'], 'products':['sr1', 'sr2', 'sr2']}) # Create df

group = df.groupby('author') # Group by author used as index
df2 = group.apply(lambda x: x['subreddit'].unique()) # List of all product per author
df2 = df2.apply(pd.Series) # Split products in multiple columns
Comment

PREVIOUS NEXT
Code Example
Python :: python tuple to dict 
Python :: urllib download file to folder 
Python :: python tkinter listbox detect selection change 
Python :: while true python 
Python :: merge two columns pandas 
Python :: how to print a string in python 
Python :: what is a slug 
Python :: how to use pip commands in pycharm 
Python :: how to add csrf token in python requests 
Python :: end in print python 
Python :: create new column with length of old column value python 
Python :: python get pixel 
Python :: how to append two numpy arrays 
Python :: python random array 
Python :: how to make button in python 
Python :: pandas row sum 
Python :: local ip 
Python :: forgot django admin password 
Python :: how to add to the end of an array python 
Python :: csv len python 
Python :: python first three characters of string 
Python :: rstrip in python 
Python :: Iterate through string backwards in python 
Python :: python count same number in list 
Python :: hashing in python using chaining in python 
Python :: python mathematics 
Python :: python save button 
Python :: binary to string python 
Python :: while activating env show error of unautorize access in vscode 
Python :: replace comma with dot in column pandas 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =