pandasql
from pandasql import sqldf
from sklearn.datasets import load_iris
iris = load_iris()
print iris.DESCR
print iris.feature_names
print iris.data[:10]
print iris.data.shape
import re
columns = [re.sub("[() ]","",col) for col in iris.feature_names] #delete space and "()" from columns name
iris_df = pd.DataFrame(iris.data, columns = columns)
iris_df['species'] = [iris.target_names[i] for i in iris.target]
print iris.target
print iris.target_names
pysqldf = lambda q: sqldf(q, globals())
pysqldf("select sepalwidthcm, species from iris_df limit 10;")
q= "select species, avg(sepalwidthcm), min(sepalwidthcm), max(sepalwidthcm),from iris_df group by species;"
print pysqldf(q)