Add VT2-examples: all 6 chapters of 'Visualize This' (110 files) — data scraping, ETL, trends, categorical, multivariate, spatial, distribution analysis
This commit is contained in:
1 parent
088771a9cf
commit
b42b866a8c
110 files changed
+400895
No files matched your search
@@ -0,0 +1,26 @@
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
|
||||
|
||||
# Load CSV
|
||||
people = pd.read_csv('income-scraped.csv')
|
||||
|
||||
# See first rows.
|
||||
people.head()
|
||||
|
||||
# Subset.
|
||||
over40 = people[people.AGE > 40]
|
||||
over40.head()
|
||||
|
||||
# New column.
|
||||
people['isover40'] = people['AGE'] > 40
|
||||
people['agegrp'] = (people['AGE'] / 10).apply(np.floor) * 10
|
||||
|
||||
|
||||
# Median.
|
||||
people['FTOTINC'].median()
|
||||
|
||||
|
||||
# Grouped median.
|
||||
people.groupby(['isover40'])['FTOTINC'].median()
|
||||
people.groupby(['agegrp'])['FTOTINC'].median()
|
||||
Reference in new issue
Block a user