pandas 1.4.2

ParametersReturns
info(self, verbose: 'bool | None' = None, buf: 'IO[str] | None' = None, max_cols: 'int | None' = None, memory_usage: 'bool | str | None' = None, show_counts: 'bool' = True) -> 'None'

This method prints information about a Series including the index dtype, non-null values and memory usage.

versionadded

Parameters

data : Series

Series to print information about.

verbose : bool, optional

Whether to print the full summary. By default, the setting in pandas.options.display.max_info_columns is followed.

buf : writable buffer, defaults to sys.stdout

Where to send the output. By default, the output is printed to sys.stdout. Pass a writable buffer if you need to further process the output.

memory_usage : bool, str, optional

Specifies whether total memory usage of the Series elements (including the index) should be displayed. By default, this follows the pandas.options.display.memory_usage setting.

True always show memory usage. False never shows memory usage. A value of 'deep' is equivalent to "True with deep introspection". Memory usage is shown in human-readable units (base-2 representation). Without deep introspection a memory estimation is made based in column dtype and number of rows assuming values consume the same memory amount for corresponding dtypes. With deep memory introspection, a real memory usage calculation is performed at the cost of computational resources.

show_counts : bool, optional

Whether to show the non-null counts. By default, this is shown only if the DataFrame is smaller than pandas.options.display.max_info_rows and pandas.options.display.max_info_columns . A value of True always shows the counts, and False never shows the counts.

Returns

None

This method prints a summary of a Series and returns None.

Print a concise summary of a Series.

See Also

Series.describe

Generate descriptive statistics of Series.

Series.memory_usage

Memory usage of Series.

Examples

This example is valid syntax, but we were not able to check execution
>>> int_values = [1, 2, 3, 4, 5]
... text_values = ['alpha', 'beta', 'gamma', 'delta', 'epsilon']
... s = pd.Series(text_values, index=int_values)
... s.info() <class 'pandas.core.series.Series'> Int64Index: 5 entries, 1 to 5 Series name: None Non-Null Count Dtype -------------- ----- 5 non-null object dtypes: object(1) memory usage: 80.0+ bytes

Prints a summary excluding information about its values:

This example is valid syntax, but we were not able to check execution
>>> s.info(verbose=False)
<class 'pandas.core.series.Series'>
Int64Index: 5 entries, 1 to 5
dtypes: object(1)
memory usage: 80.0+ bytes

Pipe output of Series.info to buffer instead of sys.stdout, get buffer content and writes to a text file:

This example is valid syntax, but we were not able to check execution
>>> import io
... buffer = io.StringIO()
... s.info(buf=buffer)
... s = buffer.getvalue()
... with open("df_info.txt", "w",
...  encoding="utf-8") as f: # doctest: +SKIP
...  f.write(s) 260

The memory_usage parameter allows deep introspection mode, specially useful for big Series and fine-tune memory optimization:

This example is valid syntax, but we were not able to check execution
>>> random_strings_array = np.random.choice(['a', 'b', 'c'], 10 ** 6)
... s = pd.Series(np.random.choice(['a', 'b', 'c'], 10 ** 6))
... s.info() <class 'pandas.core.series.Series'> RangeIndex: 1000000 entries, 0 to 999999 Series name: None Non-Null Count Dtype -------------- ----- 1000000 non-null object dtypes: object(1) memory usage: 7.6+ MB
This example is valid syntax, but we were not able to check execution
>>> s.info(memory_usage='deep')
<class 'pandas.core.series.Series'>
RangeIndex: 1000000 entries, 0 to 999999
Series name: None
Non-Null Count    Dtype
--------------    -----
1000000 non-null  object
dtypes: object(1)
memory usage: 55.3 MB
See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /pandas/core/series.py#4969
type: <class 'function'>
Commit: