.. currentmodule:: pandas .. ipython:: python :suppress: import numpy as np import pandas as pd np.set_printoptions(precision=4, suppress=True) pd.options.display.max_rows = 8 index = pd.date_range('1/1/2000', periods=8) df = pd.DataFrame(np.random.randn(8, 3), index=index, columns=['A', 'B', 'C']) s = pd.Series(np.random.randn(5), index=['a', 'b', 'c', 'd', 'e']) wp = pd.Panel(np.random.randn(2, 5, 4), items=['Item1', 'Item2'], major_axis=pd.date_range('1/1/2000', periods=5), minor_axis=['A', 'B', 'C', 'D']) .. _basics.attrs: Attributes and the raw ndarray(s) --------------------------------- pandas objects have a number of attributes enabling you to access the metadata * **shape**: gives the axis dimensions of the object, consistent with ndarray * Axis labels * **Series**: *index* (only axis) * **DataFrame**: *index* (rows) and *columns* * **Panel**: *items*, *major_axis*, and *minor_axis* Note, **these attributes can be safely assigned to**! .. ipython:: python df df[:2] df.columns = [x.lower() for x in df.columns] df To get the actual data inside a data structure, one need only access the **values** property: .. ipython:: python s s.values df df.values wp wp.values If a DataFrame or Panel contains homogeneously-typed data, the ndarray can actually be modified in-place, and the changes will be reflected in the data structure. For heterogeneous data (e.g. some of the DataFrame's columns are not all the same dtype), this will not be the case. The values attribute itself, unlike the axis labels, cannot be assigned to. .. note:: When working with heterogeneous data, the dtype of the resulting ndarray will be chosen to accommodate all of the data involved. For example, if strings are involved, the result will be of object dtype. If there are only floats and integers, the resulting array will be of float dtype.