How to create dataframe with different datatypes in python?

ipython

#1

Hello,
How can one create a dataframe with different datatypes.
Thanks


#2

Hello mukesh,

This can be done by creating a dataframe out of a dictionary using pandas. Here is the code:

import pandas as pd     
d = pd.DataFrame({  'a':  pd.Series([1.0,2.0,3.0],index=[0,1,2]),
                                           'b':np.array([1,1,1]),
                                            'c':pd.date_range('20150101','20150101',freq='D')})

Check the columns type using :

d.dtypes

Series is float type ,array int and Date range datetime type.