In [1]:
import numpy as np;
import pandas as pd

In [2]:
dtypes = ['int64', 'int8', 'float64', 'datetime64[ns]', 'timedelta64[ns]','complex128', 'object', 'bool']

In [3]:
n = 5000
data = dict([ (t, np.random.randint(100, size=n).astype(t)) for t in dtypes])
df = pd.DataFrame(data)

In [4]:
df.info()


<class 'pandas.core.frame.DataFrame'>
RangeIndex: 5000 entries, 0 to 4999
Data columns (total 8 columns):
bool               5000 non-null bool
complex128         5000 non-null complex128
datetime64[ns]     5000 non-null datetime64[ns]
float64            5000 non-null float64
int64              5000 non-null int64
int8               5000 non-null int8
object             5000 non-null object
timedelta64[ns]    5000 non-null timedelta64[ns]
dtypes: bool(1), complex128(1), datetime64[ns](1), float64(1), int64(1), int8(1), object(1), timedelta64[ns](1)
memory usage: 283.3+ KB

In [5]:
pd.DataFrame(df.int8).info()


<class 'pandas.core.frame.DataFrame'>
RangeIndex: 5000 entries, 0 to 4999
Data columns (total 1 columns):
int8    5000 non-null int8
dtypes: int8(1)
memory usage: 5.0 KB

In [6]:
pd.DataFrame(df.int64).info()


<class 'pandas.core.frame.DataFrame'>
RangeIndex: 5000 entries, 0 to 4999
Data columns (total 1 columns):
int64    5000 non-null int64
dtypes: int64(1)
memory usage: 39.1 KB

In [7]:
df['categorical'] = df['object'].astype('category')

In [8]:
pd.DataFrame(df.categorical).info()


<class 'pandas.core.frame.DataFrame'>
RangeIndex: 5000 entries, 0 to 4999
Data columns (total 1 columns):
categorical    5000 non-null category
dtypes: category(1)
memory usage: 5.7 KB

In [9]:
pd.DataFrame(df.object).info()


<class 'pandas.core.frame.DataFrame'>
RangeIndex: 5000 entries, 0 to 4999
Data columns (total 1 columns):
object    5000 non-null object
dtypes: object(1)
memory usage: 39.1+ KB

In [10]:
pd.DataFrame(df.categorical).head()


Out[10]:
categorical
0 36
1 26
2 76
3 51
4 74

In [11]:
pd.DataFrame(df.object).head()


Out[11]:
object
0 36
1 26
2 76
3 51
4 74

In [12]:
df['bool'].head()


Out[12]:
0    True
1    True
2    True
3    True
4    True
Name: bool, dtype: bool

In [ ]: