Skip to content

Instantly share code, notes, and snippets.

@cab938
Created April 29, 2018 02:44
Show Gist options
  • Save cab938/0b7a361f1077e3380e5aaa3bd151fa39 to your computer and use it in GitHub Desktop.
Save cab938/0b7a361f1077e3380e5aaa3bd151fa39 to your computer and use it in GitHub Desktop.
#!pip install html5lib #install html5lib, only needs to be run once
#You might need to restart kernel after running with the menu Kernel>Restart#
import pandas as pd
import numpy as np
from scipy import stats
df=pd.read_html('https://proxy.mentoracademy.org/getContentFromUrl/?userid=user&url=https://www.ncdc.noaa.gov/cag/global/time-series/northAmerica/land/ytd/12/1880-2016', header=0)[0]
pop1=df[df['Year']<1950]['Anomaly(1910-2000 Base Period)'].apply(lambda x: x.split('°C')[0]).astype(float)
pop2=df[df['Year']>=1950]['Anomaly(1910-2000 Base Period)'].apply(lambda x: x.split('°C')[0]).astype(float)
print("Mean anomaly values before 1950 {}, and mean after 1950 {}".format(np.mean(pop1),np.mean(pop2)))
if stats.ttest_ind(pop1,pop2)[1] <= 0.01:
print("Test was statistically significant at p<0.01 value.")
else:
print("Test was not statistically significant at p<0.01 value.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment