Python matplotlib 折线图

这篇博客详细介绍了如何使用Python的matplotlib库绘制折线图,包括读取和整理数据,绘制基础折线图,以及进阶技巧如带阴影的折线图。通过实例展示了票房、人次和评价的关系,并探讨了开发者薪资情况,最后提供了完整的学习资源。
摘要由CSDN通过智能技术生成

bos=[‘61,181’,‘44,303’,‘42,439’,‘22,984’,‘13,979’,‘61,181’,‘44,303’,‘41,439’,‘20,984’,‘19,979’]

persons=[‘31’,‘23’,‘56’,‘17’,‘9’,‘31’,‘23’,‘56’,‘17’,‘9’]

prices=[‘51’,‘43’,‘56’,‘57’,‘49’,‘51’,‘43’,‘56’,‘57’,‘49’]

showdate=[‘2022-12-03’,‘2022-12-05’,‘2022-12-01’,‘2022-12-02’,‘2022-11-05’,‘2022-12-03’,‘2022-12-05’,‘2022-12-01’,‘2022-12-02’,‘2022-11-05’]

ftypes=[‘剧情’,‘动作’,‘喜剧’,‘剧情’,‘剧情’,‘爱情’,‘动作’,‘动画’,‘动画’,‘动画’]

points=[‘8.1’,‘9.0’,‘7.9’,‘6.7’,‘3.8’,‘8.1’,‘9.0’,‘7.9’,‘6.7’,‘3.8’]

filmdescript={

‘ftypes’:ftypes,

‘bos’:bos,

‘prices’:prices,

‘persons’:persons,

‘regions’:regions,

‘showdate’:showdate,

‘points’:points

}

import numpy as np

import pandas as pd

cnbo2021top5=pd.DataFrame(filmdescript,index=films)

cnbo2021top5[[‘prices’,‘persons’]]=cnbo2021top5[[‘prices’,‘persons’]].astype(int)

cnbo2021top5[‘bos’]=cnbo2021top5[‘bos’].str.replace(‘,’,‘’).astype(int)

cnbo2021top5[‘showdate’]=cnbo2021top5[‘showdate’].astype(‘datetime64’)

cnbo2021top5[‘points’]=cnbo2021top5[‘points’].apply(lambda x:float(x) if x!=‘’ else 0)

关于cnboo1.xlsx,我放在我的码云里,需要的朋友自行下载:cnboo1.xlsx

读取并初步整理数据集

import pandas as pd

cnbodf=pd.read_excel(‘cnboo1.xlsx’)

cnbodfsort=cnbodf.sort_values(by=[‘BO’],ascending=False)

在这里插入图片描述

def mkpoints(x,y): # 编写points评分

return len(str(

  • 5
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值