-
pandas.get_dummies() : one-hot 编码
https://blog.youkuaiyun.com/u010665216/article/details/78635664 -
对某一列数据统计 train[‘Survived’].value_counts()
- sns.countplot 离散,有 hue 选项
- t.groupby(’…’)[’…’].mean().plot() 连续值
- t.groupby(’…’)[’…’].mean().plot.bar() 离散, 类似于直方图吧,有点区别
- g = sns.FacetGrid(train,col=‘Survived’,height=5)
g.map(plt.hist,‘Age’,bins=40) 多个变量的子图,直方图,连续。
- 正则表达式
\d
\w
\s
.
{n}、{n,m}、 * 、 ? 、+
[]
-
str.extract()
https://www.geeksforgeeks.org/python-pandas-series-str-extract/ 重点是提取括号里面的字符。 -
str.strip()
https://www.geeksforgeeks.org/python-pandas-series-str-strip-lstrip-and-rstrip/
可以在Series后面直接跟apply() train_test[‘Name’].apply(lambda x:x.split(’.’)[1]) -
merge() 各种合并。指定好关键字。
https://pandas.pydata.org/pandas-docs/stable/user_guide/merging.html
https://blog.youkuaiyun.com/weixin_37226516/article/details/64137043 -
loc 是可以自动增加新列 ‘Name2_new’ 的,等于1的值设为 ‘one’
train_test.loc[train_test[‘Name2_sum’] == 1 , ‘Name2_new’] = ‘one’ -
寻找缺失值
train_test.loc[train_test[“Fare”].isnull()] -
补充缺数值
train_test[‘Fare’].fillna(14.64408,inplace=True) -
filter以及排除某些列的方法:
https://blog.youkuaiyun.com/dongcheng_/article/details/82901191
https://www.geeksforgeeks.org/python-pandas-dataframe-filter/