current position:Home>Python pyecharts draws a line chart, and the line breaks randomly

Python pyecharts draws a line chart, and the line breaks randomly

2022-02-02 21:06:18 CSDN Q & A

The broken line will be on the left , I'll be on the right , Non sequential connection

import pandas as pdfrom pyecharts.charts import Linefrom pyecharts import options as optj=[]shuju = []df = pd.read_csv('python.csv',encoding='gbk')sc=df.dropna(axis=0,how='any',inplace=False)#print(sc)xzlist = sc[' Salary '].tolist()print(xzlist)for xz in xzlist:    if 'K' in xz:        num1 = xz.split('K')[0].split('-')[0]        num2 = xz.split('K')[0].split('-')[1]        xinzi = (int(num1) + int(num2)) / 2 * 1000 * 12 / 10000        shuju.append(xinzi)        shuju.append(xinzi)    if ' element ' in xz:        num1 = xz.split(' element ')[0].split('-')[0]        num2 = xz.split(' element ')[0].split('-')[1]        xinzi = (int(num1) + int(num2)) / 2 * 22 * 12 / 10000        #print(xinzi)        shuju.append(xinzi)print(shuju)cj=shuju[0:30]print(cj)gslist = sc[' company '].tolist()print(gslist)gs=gslist[0:30]print(gs)l=Line()l.add_xaxis(gs)l.add_yaxis(' Salary ',cj)l.set_global_opts(title_opts=op.TitleOpts(title='python Comparison chart of monthly average salary of posts in each company '),yaxis_opts=op.AxisOpts(name=' Position salary (k/ monthly )'),                    xaxis_opts=op.AxisOpts(name=' company ',axislabel_opts=op.LabelOpts(rotate=-60)),                    datazoom_opts=op.DataZoomOpts(type_='inside'))l.render(' Broken line .html')![img]( "#left")

Refer to the answer 1:

You look at you prin(gs) The order of Is it the same as the picture ?
If you want to show , This should be more appropriate with a histogram .

Refer to the answer 2:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.

Random recommended