Duration 1:19

What is Series data structure in Data Frame For pandas, Python for Beginners

Published 1 Nov 2023

Exploring the Pandas Series Data Structure Welcome to this tutorial on Series data types in Pandas! Pandas is a popular library used for data manipulation and analysis. In this tutorial, we will be discussing the Series data type in Pandas. A Series is a one-dimensional labeled array capable of holding any data type. It is similar to a column in a spreadsheet or a SQL table. It is a basic data structure in Pandas that is used to store and manipulate data. To create a Series in Pandas, we can use the `pd.Series()` function. Let's create a simple Series containing the heights of students in a class: import pandas as pd heights = pd.Series([5.2, 5.4, 5.7, 6.0, 5.9])print(heights) This will output: and the data tpe is float64 As you can see, the Series contains the heights of 5 students and each value is assigned a label or index starting from 0. We can also assign custom labels to the index using the `index` parameter: heights = pd.Series([5.2, 5.4, 5.7, 6.0, 5.9], index=['A', 'B', 'C', 'D', 'E'])print(heights) This will output dtype: float64 Now, the index labels are assigned as 'A', 'B', 'C', 'D', and 'E'. Series can also be created from dictionaries: heights_dict = {'A': 5.2, 'B': 5.4, 'C': 5.7, 'D': 6.0, 'E': 5.9}heights = pd.Series(heights_dict)print(heights) This will output the same result as the previous example. Congratulations on mastering the Series! We appreciate you taking the time to watch this tutorial. Keep an eye out for our upcoming tutorial on Data Frames in Pandas

Category

Show more

Comments - 0