【发布时间】:2021-04-15 15:01:56
【问题描述】:
我正在使用 Spyder 和以下源代码:
import pandas as pd
filename = "file.csv" # 5.35 GB in size
df = pd.read_csv(filename, nrows=5)
pd.set_option('display.max_columns', None)
df
输出
runfile('C:/Users/pc/Desktop/Data Mining/file.py', wdir='C:/Users/pc/Desktop/Data Mining/')
Reloaded modules: jupyter_client.session, zmq.eventloop, zmq.eventloop.ioloop,
tornado.platform, tornado.platform.asyncio, tornado.gen, zmq.eventloop.zmqstream,
jupyter_client.jsonutil, jupyter_client.adapter, spyder, spyder.pil_patch, PIL,
PIL._version, PIL.Image, PIL.ImageMode, PIL.TiffTags, PIL._binary, PIL._util, PIL._imaging,
cffi, cffi.api, cffi.lock, cffi.error, cffi.model
为什么我的 python pandas 代码不显示表格?
另外,使用 print(df) 后:
import pandas as pd
filename = "clash_royale_games_Jan_2019.csv"
df = pd.read_csv(filename, nrows=5)
pd.set_option('display.max_columns', None)
print(df)
输出
runfile('C:/Users/pc/Desktop/Data Mining/file.py', wdir='C:/Users/pc/Desktop/Data Mining/')
Reloaded modules: jupyter_client.session, zmq.eventloop, zmq.eventloop.ioloop, tornado.platform, tornado.platform.asyncio, tornado.gen, zmq.eventloop.zmqstream, jupyter_client.jsonutil, jupyter_client.adapter, spyder, spyder.pil_patch, PIL, PIL._version, PIL.Image, PIL.ImageMode, PIL.TiffTags, PIL._binary, PIL._util, PIL._imaging, cffi, cffi.api, cffi.lock, cffi.error, cffi.model
timestamp arena_id has_won tag \
0 2018-12-31T23:00:46Z 16 1 289VVL288
1 2018-12-31T23:01:34Z 14 1 2G0PRYVRU
2 2018-12-31T23:02:00Z 13 1 92GLVGQU
3 2018-12-31T23:02:00Z 14 1 2Y28RPJRC
4 2018-12-31T23:02:02Z 16 0 8RYLV2R
player_deck
0 elixir-collector_golem_mega-knight_mega-minion...
1 dark-prince_goblin-gang_miner_pekka_the-log_to...
2 baby-dragon_balloon_barbarian-barrel_bowler_fr...
3 baby-dragon_fireball_inferno-dragon_mega-minio...
4 archers_barbarian-barrel_goblins_hog-rider_kni...
您会看到第 5 列被截断。
如何完整显示第 5 列?
【问题讨论】:
-
你必须使用spyder吗? jupyter notebooks 很容易解决这个问题 - 你可以设置列宽等。(公平地说,这可能不是使用 jupyter 的功能;我只使用过没有这个问题的 jupyter 或 vs-code)
标签: python pandas data-analysis