python将第一行设置为列名_防止pandas read_csv将第一行视为列名的标题

您希望header=None将False类型提升为int到0中,请参阅docs我的重点:header : int or list of ints, default ‘infer’ Row number(s) to use as

the column names, and the start of the data. Default behavior is as if

set to 0 if no names passed, otherwise None. Explicitly pass header=0

to be able to replace existing names. The header can be a list of

integers that specify row locations for a multi-index on the columns

e.g. [0,1,3]. Intervening rows that are not specified will be skipped

(e.g. 2 in this example is skipped). Note that this parameter ignores

commented lines and empty lines if skip_blank_lines=True, so header=0

denotes the first line of data rather than the first line of the file.

你可以看到行为的不同,首先用header=0:In [95]:

import io

import pandas as pd

t="""a,b,c

0,1,2

3,4,5"""

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值