【问题标题】:I get an TypeError in python3 when I use Pandas and sep function当我使用 Pandas 和 sep 函数时,我在 python3 中得到一个 TypeError
【发布时间】:2017-02-12 14:30:57
【问题描述】:

我尝试使用 pandas 在 python 中操作一个真正的大数据集。我使用的代码如下

import numpy as np
import pandas as pd
from pandas import DataFrame
from pandas import Series
pd.set_option('display.max_columns', None)
df = pd.read_csv('Medicare.txt', 'r', sep='\t', na_values=['.'])
print (len(df))
df.head(10)

我收到的错误如下

TypeError: parser_f() got multiple values for argument 'sep'

谁能告诉我我做错了什么?

谢谢

【问题讨论】:

    标签: python pandas


    【解决方案1】:

    read_csv 的第二个位置参数是sep。出于某种原因,您在那里传递了一个“r”,以及一个明确的sep kwarg。

    【讨论】:

    • 就是这样!非常感谢。我删除了“r”,一切都按预期进行。除了我收到警告/home/antonis/anaconda3/lib/python3.6/site-packages/IPython/core/interactiveshell.py:2717: DtypeWarning: Columns (10) have mixed types. Specify dtype option on import or set low_memory=False. interactivity=interactivity, compiler=compiler, result=result) 有什么需要担心的吗?
    猜你喜欢
    • 2022-06-28
    • 1970-01-01
    • 2023-02-05
    • 2019-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-22
    相关资源
    最近更新 更多