Course Content
Python Indentation, Comments and Variables
0/2
Object Oriented Programming in Python
0/1
Exception Handling in Python
0/1
Sending emails with Python
0/1
Unit test in python programming
0/1
Python programming (zero to advance!!!)
About Lesson

2. SERIES:

A Series is a one-dimensional array-like object that can hold data of any type. It is similar to a column in a DataFrame and can be thought of as a single column of data.
A Series is a one-dimensional labeled array in Pandas, similar to a column in a DataFrame or a single column in Excel. It can hold data of any data type and is often used to represent a single variable or attribute.

Here’s an illustrative code example of creating a Series in Python using Pandas:

“`python
import pandas as pd

# Create a Series from a list
data = [10, 20, 30, 40, 50]
s = pd.Series(data)

# Display the Series
print(s)
“`

Output:
“`
0 10
1 20
2 30
3 40
4 50
dtype: int64
“`

In this example:
– We first import the Pandas library with the alias `pd`.
– Then, we create a list `data` containing five integers.
– Next, we create a Series `s` using the `pd.Series()` function, passing the `data` list as an argument.
– Finally, we display the Series using the `print()` function, which prints the contents of the Series to the console.

This creates a Series with five elements, each labeled with an index ranging from 0 to 4, and containing the values from the `data` list. The data type of the Series is automatically inferred based on the data provided (in this case, integers).

Join the conversation