Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda What is a DataFrame? | Basics of Dataframes
Pandas: First Steps
course content

Conteúdo do Curso

Pandas: First Steps

Pandas: First Steps

1. Getting Started
2. Basics of Dataframes

book
What is a DataFrame?

A DataFrame is a core data structure in Pandas used for storing and manipulating Tabular Data.

It provides many useful methods and features for analyzing, filtering, and transforming the data efficiently.

The general syntax of the DataFrame constructor is:

js

Here index and column are optional named parameters, which take up the default numerical values if not custom values are specified.

There are several ways to create a DataFrame:

Dictionary of Lists

One of the most common methods is to use a dictionary where the keys are column names and the values are lists of data.

12345678910
import pandas as pd data = { 'Name': ['Alice', 'Bob', 'Charlie'], 'Age': [25, 30, 35], 'City': ['New York', 'Paris', 'London'] } df = pd.DataFrame(data) print(df)
copy

List of Dictionaries

You can also pass a list of dictionaries, where each dictionary represents a row of data.

12345678910
import pandas as pd data = [ {'Name': 'Alice', 'Age': 25, 'City': 'New York'}, {'Name': 'Bob', 'Age': 30, 'City': 'Paris'}, {'Name': 'Charlie', 'Age': 35, 'City': 'London'} ] df = pd.DataFrame(data) print(df)
copy

2D List (List of Lists)

You can also use a list of lists (2D list). In this case you need to explicitly specify the column names in the DataFrame constructor using the columns named parameter:

12345678910
import pandas as pd data = [ ['Alice', 25, 'New York'], ['Bob', 30, 'Paris'], ['Charlie', 35, 'London'] ] df = pd.DataFrame(data, columns=['Name', 'Age', 'City']) print(df)
copy

1. What is a Pandas DataFrame?

2. Which of the following code snippets will create a DataFrame with columns "Name" and "Age"?

3. What does the columns argument in pd.DataFrame() do when using a 2D list?

question mark

What is a Pandas DataFrame?

Select the correct answer

question mark

Which of the following code snippets will create a DataFrame with columns "Name" and "Age"?

Select the correct answer

question mark

What does the columns argument in pd.DataFrame() do when using a 2D list?

Select the correct answer

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 1
Sentimos muito que algo saiu errado. O que aconteceu?
some-alt