Operations between pandas data structure
Statistics :
Operations in general exclude missing data.
import numpy as np
import pandas as pd
dates = pd.date_range('20190101', periods=8)
df = pd.DataFrame(np.random.randn(8, 4), index=dates, columns=list('PQRS'))
df.mean()
Same operation on the other axis:
df.mean(1)
Operating with objects :
s = pd.Series([1, 4, np.nan, 6, 8]).shift(2)
s
df.sub(s, axis='index')
Apply some functions to the data :
df.apply(np.cumsum)
df.apply(lambda x: x.max() - x.min())
Histogramming :
s = pd.Series(np.random.randint(0, 5, size=8))
s
s.value_counts()
String Methods :
Series is equipped with a set of string processing methods in the str attribute that make it easy to operate on each element of the array, here is an example:
s = pd.Series(['C', 'D', 'Baca', np.nan, 'CABA', 'dog', 'boy'])
s.str.lower()