Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Pandas Read CSV various datatypes

Example with a few more column-types (e.g. the column with the title MyBool contains True and False values and it is recognized as bool)

{% embed include file="src/examples/pandas/mixed.csv)

import pandas as pd

df = pd.read_csv('mixed.csv')
print( df.dtypes )
print( df.describe() )

MyText        object
MyInteger      int64
MyFloat      float64
MyBool          bool
MyExit         int64
dtype: object
       MyInteger   MyFloat    MyExit
count   3.000000  3.000000  3.000000
mean    7.333333  3.233333  1.333333
std     4.509250  0.862168  1.527525
min     3.000000  2.300000  0.000000
25%     5.000000  2.850000  0.500000
50%     7.000000  3.400000  1.000000
75%     9.500000  3.700000  2.000000
max    12.000000  4.000000  3.000000