Created
March 25, 2014 18:28
-
-
Save szeitlin/9768096 to your computer and use it in GitHub Desktop.
practicing taking data semi-blindly, importing & filtering via pandas, viewing with vincent.
This file contains 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
__author__= 'szeitlin' | |
import pandas | |
import vincent | |
MYFILE = "UNdata_Export_20140325_115007094.csv" | |
#read in a csv file | |
mydata = pandas.read_csv(MYFILE) | |
#want to get rid of the "Value Footnotes" column, because it is full of NaNs | |
mydata=mydata.drop("Value Footnotes", axis=1) #axis=1 means to drop the column | |
#then get rid of that last row that has an NaN in it | |
mydata = mydata.dropna() | |
#want "Subgroup" and "Value" columns to be easy to find | |
gender = mydata.Subgroup | |
percent = mydata.Value | |
#starting point for a graph | |
bar = vincent.Bar(percent) #use the values in the percent column for the bars | |
#longer version to add some niceties | |
bar.axis_titles(x='gender', y ='percent employed') #this worked! yay! | |
#save to a file or two | |
bar.to_json('bar.json', html_out=True, html_path='bar_template.html') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment