要安装好以下依赖

pyecharts + panda + sqlite3

import sqlite3
import pandas as pd
from pyecharts import Line



with sqlite3.connect('csi_indices.db') as con:

    # read_sql_query和read_sql都能通过SQL语句从数据库文件中获取数据信息
    df = pd.read_sql_query("SELECT * FROM indice order by index_name, statis_date", con=con)
    # df = pd.read_sql("SELECT * FROM test_table", con=con)

    # print(df.shape)
    # print(df.dtypes)
    # print(df.head())

    names=["上证50","沪深300","深证成指    ","深证100R  ","中小板指    ","上证380","红利指数","中证红利","中证500","上证指数","上证180"]

    line = Line(width=1600,height=800)
    for i, na in enumerate(names):
        na_data = df[(df.index_name == na)]
        attr = na_data["statis_date"]
        v1 = na_data["pe_ttm"]

        line.add("{} pe_ttm".format(na), attr, v1,
            yaxis_min="dataMin",
            mark_line=["average"],
            mark_point=[
                        "min",
                        "max"
                        ]
            )


    line.render()



结果如下

img

参考资料