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 :: python list append 
Python :: How to check for string membership in python 
Python :: nltk python how to tokenize text 
Python :: Pass arguments in button tkinter 
Python :: how to save plot in matplotlib 
Python :: python add columns to dataframe without changing the original 
Python :: django swagger 
Python :: how to add condition if null value in django orm 
Python :: python basics flask project 
Python :: numpy maximum 
Python :: how to get quarter year date in pandas 
Python :: pyqt click through window 
Python :: python how to make a png 
Python :: declaring array size python 
Python :: count occurrences of one variable grouped by another python 
Python :: matplotlib remove drawn text 
Python :: django form custom validation 
Python :: install python package 
Python :: init array in numpy 
Python :: gcd function in python 
Python :: difference between this and super 
Python :: Python operator to use for set union 
Python :: map function to change type of element in python 
Python :: // in python 
Python :: list programs in python 
Python :: check if text is python 
Python :: push button raspberry pi 
Python :: pandas get row if difference previous 
Python :: delete file in django terminal 
Python :: Exception in thread 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =