コード例 #1
0
ファイル: main_EDAreport.py プロジェクト: plutoese/mars
# 1. 报告的初始化
region_data = RegionData()
report = Report(title=report_title,author=report_author)
for i in range(len(vars)):
    var = vars[i]
    restvar = list(vars)
    del restvar[i]

    # 生成章节
    report.createSection(var)

    period = region_data.databases['citystatiscs'].period(var)
    for year in period:
        # 生成分支章节
        report.createSubSection(year)
        mdata = region_data.query(region=['t'],year=[year],variable=[var])
        mdata = mdata['data']
        invars = mdata.columns[1:]
        cse = CrossSectionRegionDataExplorer(mdata)
        tdata = cse.describe().applymap(lambda x:'{0:.2f}'.format(x))
        tdata = dataframe2list(tdata)
        print(var,year)
        report.addTable(tdata['data'],tdata['nrow'],tdata['ncol'])

report.flush()
report.generate_pdf(save_file)




コード例 #2
0
            var = [var]
        for v in var:
            if not (self._data[v]>0).all():
                return False
        return True

    # 储存图像
    def _save(self,savepath='E:/Report/'):
        x = str(int(datetime.now().timestamp()*1000))
        filename = savepath + 'graph/' + x + '.pdf'
        plt.savefig(filename)


if __name__ == '__main__':
    rdata = RegionData()
    mdata = rdata.query(region=['t'],year=[2010],variable=[u'地区生产总值',u'年末总人口'],scale=u'全市')
    mdata = mdata['data']
    csdexplorer = CrossSectionRegionDataExplorer(mdata)
    #dframe = csdexplorer.perVar(pop=mdata[u'年末总人口'],var=[u'地区生产总值',u'年末总人口'])
    #print(dframe)
    '''
    dframe = csdexplorer.lgVar()
    dframe2 = csdexplorer.describe().applymap(lambda x:'{0:.2f}'.format(x))
    print(dframe2)
    csdexplorer.hist(var=u'地区生产总值',save=True)
    csdexplorer.scatter(y=u'地区生产总值',x=u'年末总人口',kind='kde')
    csdexplorer.pair(vars=[u'地区生产总值',u'年末总人口'])'''

    csdexplorer.ols(y=u'地区生产总值',x=u'年末总人口')
    #print(csdexplorer.corr())
コード例 #3
0
ファイル: demo_matplotpractice.py プロジェクト: plutoese/mars
# coding=UTF-8

import matplotlib.pyplot as plt
import seaborn as sns
from application.DataWarehouse.data.class_regiondata import RegionData
from application.DataWarehouse.toolkit.class_crosssectiondataexplorer import CrossSectionRegionDataExplorer

sns.set(style="white", palette="muted", color_codes=True)

# 载入数据
rdata = RegionData()
mdata = rdata.query(region=["t"], year=[2010], variable=[u"地区生产总值", u"年末总人口"], scale=u"全市")
mdata = mdata["data"]
csdexplorer = CrossSectionRegionDataExplorer(mdata)
"""
plt.style.use('ggplot')

mdata = mdata[u'地区生产总值']
mdata.plot(kind='hist')
plt.show()
"""

print(sns.axes_style())
sns.set_style(
    "white", {"font.sans-serif": ["Microsoft YaHei", "Arial", "Liberation Sans", "Bitstream Vera Sans", "sans-serif"]}
)

mdata = mdata[u"地区生产总值"]
sns.distplot(mdata, kde=False)
plt.show()