...

/

Similarities between Series and DataFrame

Similarities between Series and DataFrame

Explore the similarities between the two data structures before diving into the unique features of DataFrames.

We'll cover the following...

We’ll be exploring a dataset from a Siena College Poll in 2018. This data has rankings of United States presidents in various attributes. We’ll pull the raw data and show how to recreate the visualization first. Then we’ll demonstrate more features of DataFrames with the presidential data.

Getting the data

Wikipedia has the data from Siena College. We can scrape the data using the following commands.

Note: Given that Wikipedia can change at any time, there is no guarantee that this code will work at the time of your taking this course.

Press + to interact
import pandas as pd
url = 'https://en.wikipedia.org/wiki/Historical_rankings_of_presidents_of_the_United_States'
pres_dfs = pd.read_html(url)
df = pres_dfs[-4]
print(pres_dfs)

Once the data was loaded, we removed some rows ...