Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pandas apply output multiple columns

df = pd.DataFrame(np.random.randint(0,10,(10,2)), columns=["random", "a"])
df[["sq_a","cube_a"]] = df.apply(lambda x: [x.a**2, x.a**3], axis=1, result_type="expand")
Comment

pandas apply output multiple columns

>>> appiled_df = df.apply(lambda row: fn(row.text), axis='columns', result_type='expand')
>>> df = pd.concat([df, appiled_df], axis='columns')
Comment

PREVIOUS NEXT
Code Example
Python :: remove unnamed columns pandas 
Python :: progress bar python text 
Python :: python get dictionary keys as list 
Python :: Week of the year Pandas 
Python :: python create dictionary from csv 
Python :: creating an entry widget for input in tkinter 
Python :: get number of key in dictionary python 
Python :: timer in python 
Python :: concatenate list of strings 
Python :: get local ip 
Python :: display image from sql with python 
Python :: python define class 
Python :: python to run excel macro 
Python :: python yeild 
Python :: lcm in python 
Python :: logging 
Python :: python timeout exception 
Python :: itertools .cycle() 
Python :: difference between method and function in pyhon 
Python :: python sys.argv 
Python :: calculate term frequency python 
Python :: python count of letters in string 
Python :: pytorch older versions 
Python :: django templates 
Python :: python cv2 write to video 
Python :: pandas dataframe sort by column 
Python :: change xticks python 
Python :: if condition dataframe python 
Python :: dm user discord.py 
Python :: Get the square root of a number in Python 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =