Status
Done
1. Basic Series Properties
df['series'].index→ Returns the index (row labels) of the Series.df['series'].name→ Returns the name of the Series (if assigned).df['series'].dtype→ Returns the data type of the Series elements.df['series'].dtypes→ Alias fordtype(same output).df['series'].shape→ Returns a tuple (n_rows,) representing dimensions.df['series'].ndim→ Returns the number of dimensions (1 for Series).df['series'].size→ Returns the number of elements in the Series.df['series'].values→ Returns the data as a NumPy array.df['series'].array→ Returns the underlyingPandasArray(extension array).
2. Boolean Checks
df['series'].empty→ ReturnsTrueif the Series is empty.df['series'].hasnans→ ReturnsTrueif the Series contains any NaN values.
3. Advanced Attributes (Less Common)
df['series'].flags→ Returns aFlagsobject with memory/performance settings.df['series'].set_flags→ Modifies theflags(e.g.,copy_on_write).df['series'].attrs→ Returns a dictionary of custom metadata attributes.
Key Notes:
- Most frequently used:
index,name,dtype,shape,size,values. - For missing values:
hasnansis useful for quick NaN checks. - Advanced use cases:
flags,set_flags, andattrsare rarely needed in everyday workflows.
Below is a detailed study note on Basic Series Properties using the Titanic dataset as a case study, structured for teaching students.
Dataset Setup: Titanic Case Study
We’ll use the Titanic dataset from Seaborn:
import pandas as pd
import seaborn as sns
# Load dataset
df = sns.load_dataset('titanic')
df.head()
‣
1. Basic Series Properties
‣
2. Boolean Checks
‣
3. Advanced Attributes
Property | Description | Common Use |
.index | Row labels/index | ✅ |
.name | Name of Series | ✅ |
.dtype / .dtypes | Data type of values | ✅ |
.shape | Tuple of (length,) | ✅ |
.ndim | Number of dimensions | ✅ |
.size | Total elements | ✅ |
.values | NumPy array | ✅ |
.array | PandasArray (extension) | ❌ |
.empty | Is Series empty? | ✅ |
.hasnans | Does it have NaNs? | ✅ |
.flags | Memory flags | ❌ |
.set_flags | Set memory flags | ❌ |
.attrs | Custom metadata | ⚠️ |