numpy, pandas,collections.Counter

--------------------------numpy---------------------------------------------

1.产生随机矩阵:np.random.rand(2,3,5) 

产生整形矩阵:np.random.randint(0,10,(4,3))

正态分布:np.random.binomial(5, 0.5, size=(2,3))

2.搜索最大数,np.max(a,axis=0)

搜索最大数位置: np.where

3.保存到txt,np.savetxt()

 

-----------------------------pandas ------------------------------------------------

1.读取csv: pd.read_csv

2.合并dataframe: pd.concat(df1,df2), 参数见链接https://www.cnblogs.com/guxh/p/9451532.html

3.onehot 其中几列: pd.get_dummies(df, columns = ["s"])

或者     size_mapping = {'XL': 3, 'L': 2,'M': 1}

    df['size'] = df['size'].map(size_mapping

4.转化成list: df.values.tolist()

 

-------------------------------collections--------------------------------------

1.Counter : 

Counter

 

 

posted @ 2019-10-11 15:33  wwwwb  阅读(369)  评论(0编辑  收藏  举报