#!/usr/bin/env python
# -*- coding:utf-8 -*-

# <editable>

def execute():
    # <editable>
    '''
    载入模块
    '''
    import pandas as pd
    from sqlalchemy import create_engine
    '''
    连接数据库
    '''
    engine = create_engine('mysql+pymysql://root:123123qwe@127.0.0.1:3306/analysis')
    '''
    选择目标数据
    '''
    # 生成数据

    params = {
        "columns": "SUNACTIVITY",
    }
    inputs = {"table": '纯随机性检验'}
    data_sql = 'select ' + params['columns'] + ' from ' + inputs['table']
    data_in = pd.read_sql_query(data_sql, engine)
    print(data_in)

    '''
    全表统计
    '''
    data_out = data_in.describe().T
    data_out.columns = ['count', 'mean', 'std', 'min', 'upper_quartile', 'median', 'lower_quartile', 'max']
    index = pd.DataFrame(data_out.index, columns=['col'], index=data_out.index)
    data_out = data_out.apply(lambda x: round(x, 2), axis=1)
    data_out = pd.concat([index, data_out], axis=1)
    '''
    将结果写出
    '''
    print(dict(data_out))


# </editable>


if __name__ == '__main__':
    execute()

 

相关文章:

  • 2021-11-26
  • 2021-07-22
  • 2022-01-19
  • 2022-12-23
  • 2021-12-18
  • 2021-09-14
  • 2021-07-22
  • 2021-08-20
猜你喜欢
  • 2021-06-23
  • 2021-09-18
  • 2021-07-20
  • 2021-12-11
  • 2021-09-24
相关资源
相似解决方案