pydata/pandas — pull request #7619 by asobrien (2014-06-30 18:44:51+00:00)
Title: ENH: dataframe memory usage

This addresses [Issue #6852](https://github.com/pydata/pandas/issues/6852).

For a sample DataFrame:

```python
df = pd.DataFrame({ 'float' : np.random.randn(10000000), 'int' : np.random.randint(0,5,size=10000000), 'date' : Timestamp('20130101'), 'string' : 'foo', 'smallint' : np.random.randint(0,5,size=10000000).astype('int16') })
```
The memory usage of the elements of each column (in units of bytes) are returned by accessing the `meminfo` method. This returns a Series:

```python
>>> df.meminfo()
date 80000000
float 80000000
int 80000000
smallint 20000000
string 80000000
dtype: int64
```

Also, the total memory usage (in a human readable format) can be found via the `info(memory_usage=True)` method:

```python
>>> df.info(memory_usage=True)

Int64Index: 10000000 entries, 0 to 9999999
Data columns (total 5 columns):
date datetime64[ns]
float float64
int int64
smallint int16
string object
dtypes: datetime64[ns](1), float64(1), int16(1), int64(1), object(1)
memory usage: 324.2 MB
```