gazetteerhk / census_explorer

Explore Hong Kong's neighborhoods through visualizations of census data
http://gazetteer.hk
MIT License
42 stars 12 forks source link

correlation viewer #50

Open hupili opened 10 years ago

hupili commented 10 years ago

like the plot I posted on Facebook.

With the assist of backend, it could be much easier.

hupili commented 10 years ago

Note the snippet here for future use.

import pandas
from pandas.stats.api import ols
df = pandas.io.parsers.read_csv('census.csv')
degree = df[(df.table==3) & (df.column=='d43_and') & (df.row=='a53_degree')][['area', 'value']]
incoming = df[(df.table==18) & (df.column=='l118_active') & (df.row=='h131_80000')][['area', 'value']]
both=degree.merge(incoming, on='area')
scatter(both['value_x'], both['value_y'])
res = ols(y=both['value_y'], x=both['value_x'])
hold(True)
plot(res.x['x'], res.y_predict)
xlabel('Degree course')
ylabel('80,000 - 99,999')
print res

download 1