.. currentmodule:: pandas .. ipython:: python :suppress: import numpy as np import pandas as pd import os np.random.seed(123456) np.set_printoptions(precision=4, suppress=True) import matplotlib matplotlib.style.use('ggplot') import matplotlib.pyplot as plt pd.options.display.max_rows = 8 Object Creation --------------- See the :ref:`Data Structure Intro section ` Creating a :class:`Series` by passing a list of values, letting pandas create a default integer index: .. ipython:: python s = pd.Series([1,3,5,np.nan,6,8]) s Creating a :class:`DataFrame` by passing a numpy array, with a datetime index and labeled columns: .. ipython:: python dates = pd.date_range('20130101', periods=6) dates df = pd.DataFrame(np.random.randn(6,4), index=dates, columns=list('ABCD')) df Creating a ``DataFrame`` by passing a dict of objects that can be converted to series-like. .. ipython:: python df2 = pd.DataFrame({ 'A' : 1., 'B' : pd.Timestamp('20130102'), 'C' : pd.Series(1,index=list(range(4)),dtype='float32'), 'D' : np.array([3] * 4,dtype='int32'), 'E' : pd.Categorical(["test","train","test","train"]), 'F' : 'foo' }) df2 Having specific :ref:`dtypes ` .. ipython:: python df2.dtypes