https://hackmd.io/@shaoeChen/H10_LR2gz?type=view
Today’s note on GitHub:
https://github.com/jumpingchu/Notes/blob/master/Seaborn%20Practice.ipynb
Series.str.endswith(pat, na=nan)
Test if the end of each string element matches a pattern.
>>> s = pd.Series(['bat', 'bear', 'caT', np.nan]) >>> s.str.endswith('t') 0 True 1 False 2 False 3 NaN
>>> s.str.endswith('t', na=False) 0 True 1 False 2 False 3 False
Series.corr(other, method=’pearson’, min_periods=None)
Compute correlation with other Series, excluding missing values.
>>> histogram_intersection = lambda a, b: np.minimum(a, b).sum().round(decimals=1) >>> s1 = pd.Series([.2, .0, .6, .2]) >>> s2 = pd.Series([.3, .6, .0, .1]) >>> s1.corr(s2, method=histogram_intersection) 0.3
DataFrame.nunique(axis=0, dropna=True)
Count distinct observations over requested axis.
>>> df = pd.DataFrame({'A': [1, 2, 3], 'B': [1, 1, 1]})
>>> df.nunique()
A 3
B 1
各index(A,B)中,有多少個不同的值
>>> df.nunique(axis=1) 0 1 1 2 2 2
[1, 2, 3]
[1, 1, 1]
各column中
column[0]有1個不同的值
column[1]、[2]有2個不同的值