#Create DataFrame
import pandas as pd
import numpy as np
from pandas import DataFrame, Series
df = DataFrame(
{'integer':[1,2,3,6,7,23,8,3],
'float':[2,3.4,5,6,2,4.7,4,8],
'string':['saya',None,'aku','cinta','kamu','a','b','jika']}
)
#Show DataFrame
df
#Drop Na Value from DataFrame and then change the value using map
df['string'].dropna().map(lambda x : 'rischan_' + x)
#Apply function for all rows in dataframe
df.ix[:,['float','integer']].apply(np.sqrt)
#Apply map function example
def applymap_function(x):
if type(x) is str:
return 'applymap_' +x
elif x:
return 100 * x
else:
return
#DataFrame after function excecution
df.applymap(applymap_function)
#Columns opereration in DataFrame
df["total"] = df["float"]+df["integer"]
df
#String operation in DataFrame
df["upper"] = df["string"].str.upper()
df