Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Understanding Series | Pandas Foundations
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Introduction to Pandas with AI

bookUnderstanding Series

AI in Action

12345678
import pandas as pd scores = pd.Series([88, 92, 79, 93], index=["Alice", "Bob", "Carol", "Dan"], name="Exam Scores") print(scores) print(scores.index) print(scores.dtype) print(scores.size)
copy
Note
Definition

A Series is the simplest pandas data structure: a one-dimensional labeled array. You can think of it as a single column of a table, with values and an index that labels them.

Creating Series

You can create a Series from common Python data structures, such as dictionaries and lists.

From a Dictionary

1234
import pandas as pd scores = pd.Series({"Alice": 88, "Bob": 92, "Carol": 79, "Dan": 93}) print(scores)
copy

Here, dictionary keys become the index labels.

From a List

1234
import pandas as pd grades = pd.Series([88, 92, 79, 93]) print(grades)
copy

Pandas automatically generates an index (0, 1, 2, 3).

Metadata

A Series also carries information about itself:

12345678
import pandas as pd grades = pd.Series([88, 92, 79, 93], name="Exam Scores") print(grades.index) print(grades.dtype) print(grades.name) print(grades.size)
copy
  • .index: index labels;
  • .dtype: data type of values;
  • .name: name of the Series;
  • .size: number of elements.

1. What are the two main components of a pandas Series?

2. Which attribute shows the data type of a Series?

question mark

What are the two main components of a pandas Series?

Select the correct answer

question mark

Which attribute shows the data type of a Series?

Select the correct answer

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 1. Capítulo 2

Pregunte a AI

expand

Pregunte a AI

ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

Suggested prompts:

Can you explain what a pandas Series is?

What is the difference between creating a Series from a list and from a dictionary?

Can you show more examples of Series metadata?

bookUnderstanding Series

Desliza para mostrar el menú

AI in Action

12345678
import pandas as pd scores = pd.Series([88, 92, 79, 93], index=["Alice", "Bob", "Carol", "Dan"], name="Exam Scores") print(scores) print(scores.index) print(scores.dtype) print(scores.size)
copy
Note
Definition

A Series is the simplest pandas data structure: a one-dimensional labeled array. You can think of it as a single column of a table, with values and an index that labels them.

Creating Series

You can create a Series from common Python data structures, such as dictionaries and lists.

From a Dictionary

1234
import pandas as pd scores = pd.Series({"Alice": 88, "Bob": 92, "Carol": 79, "Dan": 93}) print(scores)
copy

Here, dictionary keys become the index labels.

From a List

1234
import pandas as pd grades = pd.Series([88, 92, 79, 93]) print(grades)
copy

Pandas automatically generates an index (0, 1, 2, 3).

Metadata

A Series also carries information about itself:

12345678
import pandas as pd grades = pd.Series([88, 92, 79, 93], name="Exam Scores") print(grades.index) print(grades.dtype) print(grades.name) print(grades.size)
copy
  • .index: index labels;
  • .dtype: data type of values;
  • .name: name of the Series;
  • .size: number of elements.

1. What are the two main components of a pandas Series?

2. Which attribute shows the data type of a Series?

question mark

What are the two main components of a pandas Series?

Select the correct answer

question mark

Which attribute shows the data type of a Series?

Select the correct answer

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 1. Capítulo 2
some-alt