Pandas Series Attributes
Pandas attributes refers to the properties that tells the information about the core data structure like DataFrame and series. They simply return the metadata.
attributes do not need parenthesis.
Below are the following attributes of Series.
1. Basic Information Attributes
size: It returns the total number of elements in the Series.
Example:marks.sizeshape: It returns the dimensions of the Series as a tuple.
Example:marks.shapendim: It returns the number of dimensions of the Series. A Series is a 1D array.
Example:marks.ndimdtype: It returns the data type of the elements in the Series.
Example:marks.dtype
nbytes: It returns the number of bytes consumed by the Series data.
Example:marks.nbytesmemory_usage: It returns the memory usage of the Series.
Example:marks.memory_usage()
2. Index & Label Related Attributes
index: It returns all the index values of the Series.
Example:marks.indexaxes: It returns a list containing the index axis of the Series.
Example:marks.axesname: It returns the name of the Series.
Example:marks.nameflags: It provides information about the properties of the underlying data.
Example:marks.flagsarray: It returns the underlying ExtensionArray containing the values.
Example:marks.array
3. Data & Value Related Attributes
values: It returns the values of the Series as a NumPy array.
Example:marks.valueshasnans: It returns
Trueif the Series contains any missing values.
Example:marks.hasnansis_unique: It returns
Trueif all values in the Series are unique.
Example:marks.is_uniqueis_monotonic_increasing: It returns
Trueif the values are continuously increasing.
Example:marks.is_monotonic_increasingis_monotonic_decreasing: It returns
Trueif the values are continuously decreasing.
Example:marks.is_monotonic_decreasingempty: It returns
Trueif the Series contains no elements.
Example:marks.empty
4. Data Type / Type Information
dtype: It returns the data type of the Series.
Example:marks.dtypedtypes: It returns the data type of the Series.
Example:marks.dtypesarray: It returns the underlying array of the Series.
Example:marks.arrayvalues: It returns the underlying values.
Example:marks.values
5. Statistical / Numerical Information
These properties are used while working with numerical Series:
nbytes: Memory consumed by the values.
size: Number of elements.
shape: Dimensions of the Series.
ndim: Number of dimensions.
hasnans: Whether missing values are present.
is_unique: Whether all values are unique.
is_monotonic_increasing: Whether values are increasing.
is_monotonic_decreasing: Whether values are decreasing.