In [2]:
dft
Out[2]:
str1 str2 str3 float64 int64 float32 int8 bool date1 date2 date3 delta
0 foo bar qux 0.673861 1 0.891567 1 False 2001-01-02 2015-01-01 2011-06-24 0 days
1 foo bar qux 0.790584 1 0.846940 1 False 2001-01-02 2015-01-02 2011-06-24 1 days
2 foo bar qux 0.479642 1 0.223100 1 False 2001-01-02 2015-01-03 2011-06-24 2 days
In [3]:
dft.to_csv('datatypes_test_file.csv',index=False)
dfc = pd.read_csv('datatypes_test_file.csv')
dfc.dtypes
Out[3]:
str1        object
str2        object
str3        object
float64    float64
int64        int64
float32    float64
int8         int64
bool          bool
date1       object
date2       object
date3       object
delta       object
dtype: object

pandas provides various ways to specify column data types.

In [4]:
# Indicate the data types for columns
dft = pd.read_csv('datatypes_test_file.csv',
    dtype={
        "str2": "string",
        "str3": "category",
        "float32": np.float32,
        "bool": np.bool
    }, 
    parse_dates=['date1', 'date2'],
    converters={'delta': pd.to_timedelta})

# Explicitly convert dtype.
dft['str2'].astype('string', copy=False) 

# Set invalid to nan and smallest dtype.
dft['int8'] = pd.to_numeric(dft['int8'], errors="coerce",
                            downcast="integer") 

# Might be faster if date format is not standard.
dft['date3'] = pd.to_datetime(dft['date3'], format='%Y-%m-%d') 

# Explicit conversion of the column. Might be faster than using a converter.
dft['delta'] = pd.to_timedelta(dft['delta'])

dft
Out[4]:
str1 str2 str3 float64 int64 float32 int8 bool date1 date2 date3 delta
0 foo bar qux 0.673861 1 0.891567 1 False 2001-01-02 2015-01-01 2011-06-24 0 days
1 foo bar qux 0.790584 1 0.846940 1 False 2001-01-02 2015-01-02 2011-06-24 1 days
2 foo bar qux 0.479642 1 0.223100 1 False 2001-01-02 2015-01-03 2011-06-24 2 days