Pandas Tutorial · Pandas Tutorial
Pandas DataFrames
Learn all about Pandas DataFrames in this comprehensive tutorial.
5 min read intermediate
- •A Pandas DataFrame is a 2 dimensional data structure, like a 2 dimensional array, or a table with rows and columns.
- •As you can see from the result above, the DataFrame is like a table with rows and columns.
- •With the index argument, you can name your own indexes.
- •Use the named index in the loc attribute to return the specified row(s).
- •If your data sets are stored in a file, Pandas can load them into a DataFrame.
What is a DataFrame?
A Pandas DataFrame is a 2 dimensional data structure, like a 2 dimensional array, or a table with rows and columns.
python
Locate Row
As you can see from the result above, the DataFrame is like a table with rows and columns.
Pandas use the loc attribute to return one or more specified row(s)
python
Note: Note: This example returns a Pandas Series.
python
Note: Note: When using [], the
result is a Pandas DataFrame.
Named Indexes
With the index argument, you can name your own indexes.
python
Locate Named Indexes
Use the named index in the loc attribute to return the specified row(s).
python
Load Files Into a DataFrame
If your data sets are stored in a file, Pandas can load them into a DataFrame.
python
Note: You will learn more about importing files in the next chapters.
Module quiz
2 questions1
Which of the following is true about Pandas DataFrames?
2
What is the most common pitfall when working with Pandas DataFrames?
Answer all questions to submit.