我有一个数据帧bus_rev,如果我在jupyter笔记本中运行bus_rev.head(),它会显示前几行,但如果我运行print(bus_rev [0:3])或print bus_rev [0:3]它没有回报。我有以下bus_rev.dtypes的输出,谁能告诉我发生了什么?
代码:
bus_rev.dtypes
输出:
user_id object
business_id object
stars_x int64
address object
attributes object
categories object
city object
hours object
is_open int64
latitude float64
longitude float64
name object
neighborhood object
postal_code object
review_count int64
stars_y float64
state object
good_reviews bool
dtype: object
Update (didn't work):
import sys
stdout = sys.stdout
reload(sys)
sys.setdefaultencoding('utf-8')
sys.stdout = stdout
print(bus_rev3.head())
Import Code:
from collections import Counter
from datetime import datetime
import pandas as pd
t1 = datetime.now()
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
reviews = ''
with open('dataset/review.json','r') as f:
for line in f.readlines()[0:100000]:
reviews += line
testdf = pd.read_json(reviews,lines=True)
print(datetime.now() - t1)
答案 0 :(得分:0)
您在脚本开头导入了什么?似乎reload(sys)
过去曾为其他人带来过问题。