Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pandas apply

import pandas as pd

s = pd.Series([1,2,3,4,5])
  
# adding 5 to each value
new = s.apply(lambda num : num + 5)
  
# printing elements of old and new series
print(s.head().values,"
",new.head().values)
#  [1 2 3 4 5] 
#  [6 7 8 9 10]
Comment

pandas dataframe apply

df = pd.DataFrame([[4, 9]] * 3, columns=['A', 'B'])
df.apply(np.sqrt)
#     A    B
#0  2.0  3.0
#1  2.0  3.0
#2  2.0  3.0
Comment

PREVIOUS NEXT
Code Example
Python :: box plot python 
Python :: purpose of meta class in django 
Python :: nested loop 
Python :: how to parse timestamp in python 
Python :: how to make software in python 
Python :: python multiply 2 variables 
Python :: batch gradient descent python 
Python :: realtime output subprocess 
Python :: Jinja for items in list 
Python :: create random phone number python 
Python :: IQR to remove outlier 
Python :: python convert strings to chunks 
Python :: remove all elements from list python by value 
Python :: pandas groupby multiple columns 
Python :: strip whitespace python 
Python :: how to python 
Python :: array creation method in numpy 
Python :: flask api with parameter 
Python :: numpy concatenation array 
Python :: save pillow image to database django 
Python :: keras model save 
Python :: models in django 
Python :: r char to numeric dataframe all columns 
Python :: python get input 
Python :: python multithreading 
Python :: axios django post 
Python :: get xlim python 
Python :: tree python 
Python :: The datetime and django.utils.timezone modules are available, so you can do e.g. timezone.now 
Python :: how to check if string is in byte formate pythin 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =