在python 3.4.3和Pandas 0.16中,如何指定dtype索引为str?以下代码是我尝试过的:
In [1]: from io import StringIO
In [2]: import pandas as pd
In [3]: import numpy as np
In [4]: fra = pd.read_csv(StringIO('date,close\n20140101,10.2\n20140102,10.5'), index_col=0, dtype={'date': np.str_, 'close': np.float})
In [5]: fra.index
Out[5]: Int64Index([20140101, 20140102], dtype='int64')
Run Code Online (Sandbox Code Playgroud)