【问题标题】:Pandas: How to import CSV without the sep="," present at the top of the csv熊猫:如何在没有 sep="," 出现在 csv 顶部的情况下导入 CSV
【发布时间】:2020-12-09 15:19:18
【问题描述】:

我想用 pandas 导入 CSV。我的 CSV 的问题是它的顶部列中存在 sep="," 在几个文件中,因此数据框构造不正确。

Example: 
sep = ,
  Year Dec Jan
     1  50  60
     2  25  50
     3  30  30
     4  40  20
     5  10  10

注意:分隔符始终是“,”。我只是希望在将 csv 转换为数据框时将其删除。

【问题讨论】:

    标签: python-3.x pandas csv pandas-datareader


    【解决方案1】:

    尝试在pandas.read_csv() 中使用skiprows

    来自pandas documentation

    类似skiprowslist,int或可调用,可选 文件开头要跳过的行号(0-indexed)或要跳过的行数(int)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-10-30
      • 2019-11-30
      • 2021-05-16
      • 2010-12-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多