Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Series | The Very First Steps
Pandas First Steps

book
Series

Pandas offers two primary data structures: Series and DataFrame. The Series is the simpler of the two, resembling a one-dimensional array or a list. You can create a Series object using the pd.Series() constructor by passing a list as its argument.

import pandas as pd
numbers = [17, 43, 74, 20]
series = pd.Series(numbers)

print(series)
12345
import pandas as pd numbers = [17, 43, 74, 20] series = pd.Series(numbers) print(series)
copy

In this example, we use the pd.Series() constructor to create a Series object containing a list of numbers.

Task

Swipe to start coding

You are given two lists: even_numbers and states.

  • Create a Series named numbers_series from the even_numbers list.

  • Create a Series named states_series from the states list.

Solution

import pandas as pd

even_numbers = [2, 4, 8, 16]
states = ['New York', 'California', 'Chicago', 'Alaska']

# Write your code below
numbers_series = pd.Series(even_numbers)
states_series = pd.Series(states)

# Testing the result
print(numbers_series , states_series)
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 1. Chapter 2
import pandas as pd

even_numbers = [2, 4, 8, 16]
states = ['New York', 'California', 'Chicago', 'Alaska']

# Write your code below
numbers_series = ___
states_series = ___

# Testing the result
print(numbers_series , states_series)

Ask AI

expand
ChatGPT

Ask anything or try one of the suggested questions to begin our chat

some-alt