栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

pandas 的常规操作

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

pandas 的常规操作

#字符串数字化:                                                
def str_num(data):
    lis = data.columns
    for c in lis:
        lis = df[f'{c}'].unique().tolist()
        dict1 = {i:v for i,v in 
                       zip(lis,range(1,len(lis)+1))}
        df[f'{c}'] = df[f'{c}'].map(dict1)

#将数据集进行拆分成训练数据和测试数据
from sklearn.model_selection import train_test_split
X_train,X_test,y_train,y_test = train_test_split(data,target,test_size=0.2)

#随机打乱                                                          
from sklearn.utiles import shuffle                

 np.random.shuffle(indexs)

画边界图                                                                                  

#分界图需要的数据: X , Y , XY
def get_XY(data):
    x = np.linspace(data[:,0].min(), data[:,0].max(), 1000)
    y = np.linspace(data[:,1].min(), data[:,1].max(), 1000)

    X, Y = np.meshgrid(x, y)
    XY = np.c_[X.ravel(), Y.ravel()]
    return X,Y,XY

X,Y,XY = get_XY(data)
axes.pcolormesh(X,Y,y.reshape(1000,1000),shading='auto')

#搜索引擎模式,把长词继续划分的更细
jieba.lcut_for_search(s)
#全模式,尽可能的把所有的词找出来
jieba.lcut(s,cut_all=True)

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/355507.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号