data = pd.read_csv('路径/文件名.csv',encoding='utf-8')
data = data[: n] # 取前n行
data = data[['列名1', '列名2']]
data['列名'] =data['列名'].replace('被替换值', '替换值')
data = data.drop(columns=['列名1','列名2'], axis=1)
data.loc[data['列名']=='查找值']
data.loc[~data['列名'].isin(['值1','值2','值3'])]
data = data.dropna(axis=0,how='any') #drop all rows that have any NaN values
data .to_csv('./data.csv', index=False)
- 将tensor(GPU)类型数据转换为numpy类型数据
top_pred = top_pred.cpu().numpy()
pred_data = np.concatenate((pred_data, top_pred), axis=0)
pred_data = pred_data.astype(np.int)
data = pd.DataFrame(pred_data)
data.to_csv('./result/result.csv')