post two, write in org-mode, export to .md, jekyll produces .html

this is written in org-mode

it is exported with C-c C-e h k (not the pre- org 8.0 C-c C-e m m)

python is executed in org-babel blocks file:/Users/AbuDavid/personal/literateProg/blog/gapminder.csv

(setq org-babel-python-command "python3")

import sys
print(sys.version)

some modules not installed yet

pip3 install seaborn
Requirement already up-to-date: numpy in /usr/local/lib/python3.5/site-packages
Requirement already satisfied (use --upgrade to upgrade): numpy in /usr/local/lib/python3.5/site-packages

#+END~SRC~

Results append doesn’t work, because

the summary statistics are a print statement, not a return. So, use :results output

import pandas
import numpy
import statsmodels.api as sm
import statsmodels.formula.api as smf
import seaborn as sb
# bug fix for display formats to avoid run time errors
pandas.set_option('display.float_format', lambda x:'%.2f'%x)

data = pandas.read_csv('gapminder.csv')
# convert variables to numeric format using convert_objects function
data['internetuserate'] = pandas.to_numeric(data['internetuserate'], errors='coerce')
data['urbanrate'] = pandas.to_numeric(data['urbanrate'], errors='coerce')

############################################################################################
# BASIC LINEAR REGRESSION
############################################################################################
scat1 = sb.regplot(x="urbanrate", y="internetuserate", scatter=True, data=data)
# plt.xlabel('Urbanization Rate')
# plt.ylabel('Internet Use Rate')
# plt.title ('Scatterplot for the Association Between Urban Rate and Internet Use Rate')
print(scat1)

print ("OLS regression model for the association between urban rate and internet use rate")
reg1 = smf.ols('internetuserate ~ urbanrate', data=data).fit()
print (reg1.summary())

(pasted in, can’t figure out export)

begin_example

OLS regression model for the association between urban rate and internet use rate

OLS Regression Results    
_________ ________ __________ ____
Dep. Variable: internetuserate R-squared: 0.377
Model: OLS Adj. R-squared: 0.374
Method: Least Squares F-statistic: 113.7
Date: Thu, 13 Oct 2016 Prob (F-statistic): 4.56e-21
Time: 14:03:01 Log-Likelihood: -856.14
No. Observations: 190 AIC: 1716.
Df Residuals: 188 BIC: 1723.
Df Model: 1    
Covariance Type: nonrobust    
. coef std err t P>t 95.0 % Conf.Int
Intercept -4.9037 4.115 -1.192 0.235 -13.021 3.213
urbanrate 0.7202 0.068 10.665 0.000 0.587 0.853
.      
________ _______ ___________ _______
Omnibus: 10.750 Durbin-Watson: 2.097
Prob(Omnibus): 0.005 Jarque-Bera (JB): 10.990
Skew: 0.574 Prob(JB): 0.00411
Kurtosis: 3.262 Cond. No. 157.

Warnings:

[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.

insert some concluding remarks

todo: checkout code on http://kotfic.github.io/org-mode-export-of-matplotlib-images-etc.html it may help to get plots working from python.