summaryrefslogtreecommitdiffhomepage
path: root/pythonstatcomp.html.markdown
diff options
context:
space:
mode:
authorDivay Prakash <divayprakash@users.noreply.github.com>2018-10-16 22:45:43 +0530
committerGitHub <noreply@github.com>2018-10-16 22:45:43 +0530
commit5ebc12c8d99eb59d7c24864599cd470ba4ba4117 (patch)
treeaf60189b49059f81aee9a4a5823c8576d65c2fc6 /pythonstatcomp.html.markdown
parent55d1343147663911f0a5a00823639db51155637a (diff)
parenta5b7fe9e618c52399cf7bea539cafde7515a7b55 (diff)
Merge pull request #3300 from timothyubbens/update-hre
[en-us/pythonstatcomp] HRE data available in repo
Diffstat (limited to 'pythonstatcomp.html.markdown')
-rw-r--r--pythonstatcomp.html.markdown37
1 files changed, 16 insertions, 21 deletions
diff --git a/pythonstatcomp.html.markdown b/pythonstatcomp.html.markdown
index 2440d859..4cff3535 100644
--- a/pythonstatcomp.html.markdown
+++ b/pythonstatcomp.html.markdown
@@ -146,7 +146,7 @@ ggplot(aes(x="age",y="weight"), data=pets) + geom_point() + labs(title="pets")
"""
# load some data on Holy Roman Emperors
-url = "https://raw.githubusercontent.com/e99n09/R-notes/master/data/hre.csv"
+url = "https://raw.githubusercontent.com/adambard/learnxinyminutes-docs/master/hre.csv"
r = requests.get(url)
fp = "hre.csv"
with open(fp, "wb") as f:
@@ -156,26 +156,19 @@ hre = pd.read_csv(fp)
hre.head()
"""
- Ix Dynasty Name Birth Death Election 1
-0 NaN Carolingian Charles I 2 April 742 28 January 814 NaN
-1 NaN Carolingian Louis I 778 20 June 840 NaN
-2 NaN Carolingian Lothair I 795 29 September 855 NaN
-3 NaN Carolingian Louis II 825 12 August 875 NaN
-4 NaN Carolingian Charles II 13 June 823 6 October 877 NaN
-
- Election 2 Coronation 1 Coronation 2 Ceased to be Emperor
-0 NaN 25 December 800 NaN 28 January 814
-1 NaN 11 September 813 5 October 816 20 June 840
-2 NaN 5 April 823 NaN 29 September 855
-3 NaN Easter 850 18 May 872 12 August 875
-4 NaN 29 December 875 NaN 6 October 877
-
- Descent from whom 1 Descent how 1 Descent from whom 2 Descent how 2
-0 NaN NaN NaN NaN
-1 Charles I son NaN NaN
-2 Louis I son NaN NaN
-3 Lothair I son NaN NaN
-4 Louis I son NaN NaN
+ Ix Dynasty Name Birth Death
+0 NaN Carolingian Charles I 2 April 742 28 January 814
+1 NaN Carolingian Louis I 778 20 June 840
+2 NaN Carolingian Lothair I 795 29 September 855
+3 NaN Carolingian Louis II 825 12 August 875
+4 NaN Carolingian Charles II 13 June 823 6 October 877
+
+ Coronation 1 Coronation 2 Ceased to be Emperor
+0 25 December 800 NaN 28 January 814
+1 11 September 813 5 October 816 20 June 840
+2 5 April 823 NaN 29 September 855
+3 Easter 850 18 May 872 12 August 875
+4 29 December 875 NaN 6 October 877
"""
# clean the Birth and Death columns
@@ -193,6 +186,8 @@ rx = re.compile(r'\d+$') # match trailing digits
- http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.html
"""
+from functools import reduce
+
def extractYear(v):
return(pd.Series(reduce(lambda x, y: x + y, map(rx.findall, v), [])).astype(int))