常用的用法为:pandas.read_csv(‘file_name.csv’, usecols = [0,1,2,3]) 读取0,1,2,3也就是前四列,中间的数可以任意指定
# usecols 读取某一列或者某几列: import numpy as np df4=pd.read_csv("./100rowsX15cols_host.csv",usecols=["id","x0"]) print(pd.DataFrame(df4.values,dtype=np.int)) 1. 2. 3. 0 1 0 2478 0 1 4258 0 2 1664 0
>>> df = pd.read_csv(StringIO(s), usecols=[u'あああ', u'いい']) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "pandas/io/parsers.py", line 562, in parser_f return _read(filepath_or_buffer, kwds) File "pandas/io/parsers.py", line 315,...
这是一个pandas-stubs的问题。一个问题已经产生,一个PR刚刚被合并。
Describe the bug usecols keyword argument of pd.read_csv says it expects list[str] but the documentation says otherwise: Documentation (https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html): usecols list-like o...
Hi, If I have a test.csv file looks like below SecId Time Price P2 P3 10000 2013-5-11 100 10 1 500 2013-5-12 101 11 1 if I read in the above file with the following code df =pd.read_csv('test.csv', usecols=['Time', 'Price'], parse_dates=...