search
Search
Login
Unlock 100+ guides
menu
menu
web
search toc
close
Outline
Comments
Log in or sign up
Cancel
Post
account_circle
Profile
exit_to_app
Sign out
What does this mean?
Why is this true?
Give me some examples!
search
keyboard_voice
close
Searching Tips
Search for a recipe:
"Creating a table in MySQL"
Search for an API documentation: "@append"
Search for code: "!dataframe"
Apply a tag filter: "#python"
Useful Shortcuts
/ to open search panel
Esc to close search panel
to navigate between search results
d to clear all current filters
Enter to expand content preview
icon_star
Doc Search
icon_star
Code Search Beta
SORRY NOTHING FOUND!
mic
Start speaking...
Voice search is only supported in Safari and Chrome.
Navigate to

Difference between Series and DataFrame in Pandas

schedule Aug 11, 2023
Last updated
local_offer
PythonPandas
Tags
tocTable of Contents
expand_more
mode_heat
Master the mathematics behind data science with 100+ top-tier guides
Start your free 7-days trial now!

You can think of a DataFrame data structure as a standard table that is composed of rows and columns. Each column is represented by a Series data structure and a DataFrame (table) is simply a container that holds many Series objects (columns) together.

Generally speaking, the APIs available for DataFrame and Series objects are very similar with considerable overlap, however, APIs for DataFrames cater for multi-column operations, while Series APIs only cater for a single column.

DataFrame

DataFrames can be used to represent the following table that has 3 rows and 3 columns:

Name

Age

Class

0

Alex

16

A

1

Cathy

17

B

2

Bob

17

A

To create a DataFrame representing this table in Pandas, use the DataFrame constructor:

df = pd.DataFrame({
"Name": ["Alex","Cathy","Bob"],
"Age": [16,17,17],
"Class": ["A","B","A"]
})

df
Name Age Class
0 Alex 16 A
1 Cathy 17 B
2 Bob 17 A

Series

A Series is a data structure representing a single row or column of a DataFrame.

To access a particular column of a DataFrame, use the [] notation with the column label like so:

df["Name"]
0 Alex
1 Cathy
2 Bob
Name: Name, dtype: object

Here, we are accessing the Name column and the return type is Series. You can access individual values in a Series using integer indices, just as you would for standard arrays:

col_name = df["Name"] # col_name is a Series
col_name[1]
'Cathy'
robocat
Published by Arthur Yanagisawa
Edited by 0 others
Did you find this page useful?
thumb_up
thumb_down
Comment
Citation
Ask a question or leave a feedback...
thumb_up
4
thumb_down
0
chat_bubble_outline
0
settings
Enjoy our search
Hit / to insta-search docs and recipes!