ktl014
7/21/2017 - 5:07 PM

reading dataframes through panda printing types From http://pandas.pydata.org/pandas-docs/stable/io.html

reading dataframes through panda printing types From http://pandas.pydata.org/pandas-docs/stable/io.html

In [7]: data = 'a,b,c\n1,2,3\n4,5,6\n7,8,9'

In [8]: print(data)
a,b,c
1,2,3
4,5,6
7,8,9

In [9]: df = pd.read_csv(StringIO(data), dtype=object)

In [10]: df
Out[10]: 
   a  b  c
0  1  2  3
1  4  5  6
2  7  8  9

In [11]: df['a'][0]
Out[11]: '1'

In [12]: df = pd.read_csv(StringIO(data), dtype={'b': object, 'c': np.float64})

In [13]: df.dtypes
Out[13]: 
a      int64
b     object
c    float64
dtype: object