pyechats df数据生成折线图

导包

import pyecharts.options as opts

from pyecharts.faker import Faker

from pyecharts.charts import Line

from pyecharts.globals import ThemeType

import numpy as np

import pandas as pd

数据 纯属虚构

months = pd.DataFrame(pd.date_range("2018/9/30","2020/1/31",freq="M"),columns=["Date"])

months["Date"] = months.Date.map(lambda x:x.strftime("%Y-%m"))

months["Value"]= [54986,54946,54931,54778,54730,54619,54512,54492,54446,54382,54314,54288,54278,54256,54240,54191,54185]

画图

line =(Line(init_opts = opts.InitOpts(width="800px",height="400px",theme = ThemeType.DARK))

      .add_xaxis(list(months.Date))

      .add_yaxis("房价",list(months.Value))

      .set_global_opts(title_opts = opts.TitleOpts(title = "房价走势图",subtitle="单位: 元/m2"),

                                 yaxis_opts = opts.AxisOpts(min_=54000,max_=55000),

                                 xaxis_opts = opts.AxisOpts(axislabel_opts = opts.LabelOpts(rotate = 60))))

line.render_notebook()

数据纯属虚构

你可能感兴趣的:(pyechats df数据生成折线图)