Skip to main content

__ Back to top

__ ` Ctrl ` \+ ` K `

[ ![pandas 2.2.1 documentation - Home](../_static/pandas.svg) ](../index.html)

Site Navigation

  * [ Getting started ](../getting_started/index.html)
  * [ User Guide ](index.html)
  * [ API reference ](../reference/index.html)
  * [ Development ](../development/index.html)
  * [ Release notes ](../whatsnew/index.html)

  * [ __ GitHub  ](https://github.com/pandas-dev/pandas "GitHub")
  * [ __ Twitter  ](https://twitter.com/pandas_dev "Twitter")
  * [ __ Mastodon  ](https://fosstodon.org/@pandas_dev "Mastodon")

Site Navigation

  * [ Getting started ](../getting_started/index.html)
  * [ User Guide ](index.html)
  * [ API reference ](../reference/index.html)
  * [ Development ](../development/index.html)
  * [ Release notes ](../whatsnew/index.html)

  * [ __ GitHub  ](https://github.com/pandas-dev/pandas "GitHub")
  * [ __ Twitter  ](https://twitter.com/pandas_dev "Twitter")
  * [ __ Mastodon  ](https://fosstodon.org/@pandas_dev "Mastodon")

  * [ 10 minutes to pandas ](10min.html)
  * [ Intro to data structures ](dsintro.html)
  * [ Essential basic functionality ](basics.html)
  * [ IO tools (text, CSV, HDF5, â¦) ](io.html)
  * [ PyArrow Functionality ](pyarrow.html)
  * [ Indexing and selecting data ](indexing.html)
  * [ MultiIndex / advanced indexing ](advanced.html)
  * [ Copy-on-Write (CoW) ](copy_on_write.html)
  * [ Merge, join, concatenate and compare ](merging.html)
  * [ Reshaping and pivot tables ](reshaping.html)
  * [ Working with text data ](text.html)
  * [ Working with missing data ](missing_data.html)
  * [ Duplicate Labels ](duplicates.html)
  * [ Categorical data ](categorical.html)
  * [ Nullable integer data type ](integer_na.html)
  * [ Nullable Boolean data type ](boolean.html)
  * [ Chart visualization ](visualization.html)
  * [ Table Visualization ](style.html)
  * [ Group by: split-apply-combine ](groupby.html)
  * [ Windowing operations ](window.html)
  * [ Time series / date functionality ](timeseries.html)
  * [ Time deltas ](timedeltas.html)
  * [ Options and settings ](options.html)
  * [ Enhancing performance ](enhancingperf.html)
  * [ Scaling to large datasets ](scale.html)
  * [ Sparse data structures ](sparse.html)
  * Frequently Asked Questions (FAQ) 
  * [ Cookbook ](cookbook.html)

  * [ __ ](../index.html)
  * [ User Guide ](index.html)
  * Frequently... 

#  Frequently Asked Questions (FAQ)  #

##  DataFrame memory usage  #

The memory usage of a [ ` DataFrame  `
](../reference/api/pandas.DataFrame.html#pandas.DataFrame "pandas.DataFrame")
(including the index) is shown when calling the [ ` info()  `
](../reference/api/pandas.DataFrame.info.html#pandas.DataFrame.info
"pandas.DataFrame.info") . A configuration option, ` display.memory_usage  `
(see [ the list of options  ](options.html#options-available) ), specifies if
the [ ` DataFrame  ` ](../reference/api/pandas.DataFrame.html#pandas.DataFrame
"pandas.DataFrame") memory usage will be displayed when invoking the [ `
info()  ` ](../reference/api/pandas.DataFrame.info.html#pandas.DataFrame.info
"pandas.DataFrame.info") method.

For example, the memory usage of the [ ` DataFrame  `
](../reference/api/pandas.DataFrame.html#pandas.DataFrame "pandas.DataFrame")
below is shown when calling [ ` info()  `
](../reference/api/pandas.DataFrame.info.html#pandas.DataFrame.info
"pandas.DataFrame.info") :

    
    
    In [1]: dtypes = [
       ...:     "int64",
       ...:     "float64",
       ...:     "datetime64[ns]",
       ...:     "timedelta64[ns]",
       ...:     "complex128",
       ...:     "object",
       ...:     "bool",
       ...: ]
       ...: 
    
    In [2]: n = 5000
    
    In [3]: data = {t: np.random.randint(100, size=n).astype(t) for t in dtypes}
    
    In [4]: df = pd.DataFrame(data)
    
    In [5]: df["categorical"] = df["object"].astype("category")
    
    In [6]: df.info()
    <class 'pandas.core.frame.DataFrame'>
    RangeIndex: 5000 entries, 0 to 49