【问题标题】:How to resolve :first argument must be an iterable of pandas objects, you passed an object of type "DataFrame" in Pandas如何解决:第一个参数必须是 pandas 对象的可迭代对象,您在 Pandas 中传递了一个“DataFrame”类型的对象
【发布时间】:2021-10-26 08:44:05
【问题描述】:

我收到此错误:

first argument must be an iterable of pandas objects, you passed an object of type "DataFrame".

我的代码:

for f in
    glob.glob("C:/Users/panksain/Desktop/aovaNALYSIS/CX AOV/Report*.csv"):
    data = pd.concat(pd.read_csv(f,header = None, names = ("Metric Period", "")), axis=0, ignore_index=True)

【问题讨论】:

    标签: pandas csv concatenation


    【解决方案1】:

    concat 获取要连接的数据帧列表。您可以先构建列表,然后再进行连接:

    dfs = []
    for f in glob.glob("C:/Users/panksain/Desktop/aov aNALYSIS/CX AOV/Report*.csv"):
        dfs.append(pd.read_csv(f,header = None, names = ("Metric Period", "")))
    data = pd.concat(dfs, axis=0, ignore_index=True)
    

    【讨论】:

      猜你喜欢
      • 2022-08-24
      • 1970-01-01
      • 1970-01-01
      • 2021-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多