首页 > 其他 > 详细

pandas处理行数据

时间:2021-09-04 01:07:08      阅读:30      评论:0      收藏:0      [点我收藏+]
# In[1]
import os

path = ‘/home/zjdou/jupyter/root/Smart-Writing/TextClassification/DATA‘
os.chdir(path)
print(os.getcwd())

# In[2]
import pandas as pd
import numpy as np

file01 = pd.read_json(‘./raw_data/gov01.json‘)
file01

file02 = pd.read_json(‘./raw_data/gov02.json‘)
file02

total = file01.append(file02, ignore_index=True)

# In[2]
no_label_idx = total[total[‘topics‘].apply(lambda x:x[0]) == ‘‘].index
no_label_idx

total.drop(no_label_idx, inplace=True)
total.reset_index(drop=True, inplace=True)

# In[2]
total[‘topics‘] = total[‘topics‘].apply(lambda x:x[0])
total

# In[3]
total.to_json(‘./swtc/total.json‘)

# In[4]
# 分割数据

pandas处理行数据

原文:https://www.cnblogs.com/douzujun/p/15221052.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!