Python
6-Tong
a super student in BUPT!
展开
-
DataFrame导CSV txt || 每行有双引号的原因及解决办法
1.DataFrame导出到csv文件其中:index是否要索引,header是否要列名,True就是需要outputpath='d:/Users/chen_lib/Desktop/fenci.csv'df.to_csv(outputpath,sep=',',index=False,header=False)2.DataFrame导出到xlsx文件outputpath='d:/Users/chen_lib/Desktop/fenci.xlsx'df.to_excel(outputpath,se原创 2021-08-06 14:34:19 · 3381 阅读 · 0 评论 -
dataframe 删除空行及去重
df=df[~(df['col'].isnull())] #删掉空行 df=df.dropna(axis=0) #删除有空值的行,使用参数axis=0 df=df.dropna(axis=1) #删除有空值的列,使用参数axis=1原创 2021-08-06 14:14:49 · 4263 阅读 · 0 评论 -
从一个dataframe中去掉领个dataframe的部分
df_a_filter = df_a[~ df_a['uid'].isin(df_b['uid'])]参考:https://zhuanlan.zhihu.com/p/37378190原创 2021-07-30 15:50:15 · 1485 阅读 · 1 评论 -
skLearn 特征工程
参考:https://github.com/fuqiuai/sklearn-feature-engineeringfrom sklearn.feature_selection import SelectFromModelfrom sklearn.linear_model import LogisticRegressionfrom sklearn.feature_selection import RFEfrom sklearn.feature_selection import chi2from s原创 2021-07-20 10:58:23 · 118 阅读 · 0 评论 -
Excel的各Sheet 转csv文件
import xlrdimport pandas as pdimport osdef excel2csv(excel_file): # 打开excel文件 workbook=xlrd.open_workbook(excel_file) # 获取所有sheet名字 sheet_names=workbook.sheet_names() for worksheet_name in sheet_names: # 遍历每个sheet并用Pandas读取原创 2021-06-28 22:58:13 · 964 阅读 · 0 评论