This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!pip install html5lib #install html5lib, only needs to be run once | |
import pandas as pd | |
import numpy as np | |
df=pd.read_html('https://proxy.mentoracademy.org/getContentFromUrl/?userid=brooks&url=https://en.wikipedia.org/wiki/List_of_natural_satellites', header=0) | |
moons=df[4][1:] #drop prehistoric moon sighting | |
moons=moons['Discovery year'] #we are only interested in the year discovered | |
moons=moons.apply(lambda x: x.split('/')[0]).astype(int) #clean dataframe to just years as ints | |
pre_2000=len(moons[moons<2000]) #select only that data from moons which is less than 2000 | |
post_2000=len(moons[moons>=2000]) #select only that data from moons which is greater than or equal to 2000 |
NewerOlder