Attributes are the properties of any object. Here we will discuss all the Series attributes with programming examples. All the important **Series attributes** according to the CBSE **Class 12 Informatics practices** syllabus are given below in the table:-

Attributes | Description |
---|---|

Series.index | Range of the index (axis labels) of the Series. |

Series.values | Return Series as ndarray or ndarray like depending upon dtype |

Series.dtype | Return the dtype object of the underlying data. |

Series.shape | Return a tuple of the shape of the underlying data. |

Series.nbytes | Return the number of bytes in the underlying data. |

Series.ndim | The number of dimensions of the underlying data, by definition 1. |

Series.size | Return the number of elements in the underlying data. |

Series.hasnans | Return if I have any nans; enables various perf speedups. |

Series.empty | Return true if Series is empty |

at, iat | To access a single value from Series |

loc, iloc | To access slices from Series |

**Student**and check all the attributes on this

**Series Student**.

1 2 3 4 5 6 7 8 9 10 11 12 | import pandas as pd student = pd.Series(["Sonal", "Rahul", "Mohan", "Siya",]) print(student) ''' |

1 2 | >>> student.index RangeIndex(start=0, stop=4, step=1) |

2. Series.values

**values**attribute returns Series as ndarray or ndarray like depending upon dtype.

1 2 | >>> student.values array(['Sonal', 'Rahul', 'Mohan', 'Siya'], dtype=object) |

**dtype**attribute is used to check the data type of the Series Object. Since the student series is of object type, below output is showing 'o'.

1 2 | >>> student.dtype dtype('O') |

**shape**attribute gives the shape of the underlying data structure in the form of a tuple. Since the student Series is having 4 elements the output is (4,).

1 2 | >>> student.shape (4,) |

**nbyte**attribute gives the total number of bytes taken by the Series object to store the data. The below-given output tells that the student object takes 32 bytes of memory.

1 2 | >>> student.nbytes 32 |

**ndim**gives the dimension of the underlying data structure. Since series is a 1-D data structure, for all series object it gives 1.

1 2 | >>> student.ndim 1 |

**size**gives the total number of elements in the series. Since the student series has 4 elements size will give 4.

1 2 | >>> student.size 4 |

**hasnans**returns Boolean value. If any of the series elements is NaN it will return

**True.**Otherwise false.

1 2 | >>> student.hasnans False |

**empty**attribute returns Boolean True if Series is empty, otherwise the output will be False.

1 2 | >>> student.empty False |

**at**and

**iat**in detail in our upcoming Post. You can click here to go to the post.

**loc**and

**iloc**in detail in our upcoming Post. You can click here to go to the post.