pandas.read_csv导入一千多万行数据后,服务器崩溃

问题

# 导入相关库
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt

%matplotlib inline
plt.style.use('ggplot')    

# 导入数据
user = pd.read_csv('tianchi_mobile_recommend_train_user.csv')
user.head()

服务似乎挂掉了,但是会立刻重启的.

解决方案

每次读取100万行数据

df = pd.read_csv('tianchi_mobile_recommend_train_user.csv',nrows=1000000)

猜你喜欢

转载自blog.csdn.net/hezuijiudexiaobai/article/details/112171766