使用 Pandas 将一列分成多列

时间:2021-04-28 09:04:02

标签: python pandas dataframe

我正在尝试使用 Pandas 加载数据集并以表格形式显示它们。但我不确定为什么不能使用分隔符将其分开。有人知道吗?

这是我得到的输出: This is the output got by me.

我的预期输出是这样的: enter image description here

我使用的数据集:https://www.kaggle.com/tunguz/big-five-personality-test

1 个答案:

答案 0 :(得分:1)

根据评论,这对我有用。避免手动下载问题的一种方法是自动下载

  1. pip3 install kaggle
  2. 按照 CLI 的指示放置 kaggle.json
  3. 然后可以使用以下代码在 jupyter 中下载 Kaggle 数据
import kaggle.cli
import sys
from pathlib import Path
if not Path.cwd().joinpath("IPIP-FFM-data-8Nov2018/data-final.csv").exists():
    sys.argv = [sys.argv[0]] + "datasets download tunguz/big-five-personality-test --unzip".split(" ")
    kaggle.cli.main()
    
pd.read_csv(Path.cwd().joinpath("IPIP-FFM-data-8Nov2018/data-final.csv"), sep="\t")
相关问题