pyecharts应用3 Faker函数库
Posted 刘文巾
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了pyecharts应用3 Faker函数库相关的知识,希望对你有一定的参考价值。
Faker函数库里面可以随机生成一些数据
1,导入库
from pyecharts.faker import Faker
2,Faker函数库中和数据相关的部分
Faker.clothes | ["衬衫", "毛衣", "领带", "裤子", "风衣", "高跟鞋", "袜子"] |
Faker.drinks | ["可乐", "雪碧", "橙汁", "绿茶", "奶茶", "百威", "青岛"] |
Faker.phones | ["小米", "三星", "华为", "苹果", "魅族", "VIVO", "OPPO"] |
Faker.fruits | ["草莓", "芒果", "葡萄", "雪梨", "西瓜", "柠檬", "车厘子"] |
Faker.animal | ["河马", "蟒蛇", "老虎", "大象", "兔子", "熊猫", "狮子"] |
Faker.cars | ["宝马", "法拉利", "奔驰", "奥迪", "大众", "丰田", "特斯拉"] |
Faker.dogs | ["哈士奇", "萨摩耶", "泰迪", "金毛", "牧羊犬", "吉娃娃", "柯基"] |
Faker.week | ["周一", "周二", "周三", "周四", "周五", "周六", "周日"] |
Faker.week_en | ['Saturday', 'Friday', 'Thursday', 'Wednesday', 'Tuesday', 'Monday', 'Sunday'] |
Faker.clock | ['12a','1a','2a','3a','4a','5a','6a','7a','8a','9a','10a','11a', '12p','1p','2p','3p','4p','5p','6p','7p','8p','9p','10p','11p'] |
Faker.visual_color | [ "#313695", "#4575b4", "#74add1", "#abd9e9", "#e0f3f8", "#ffffbf", "#fee090","#fdae61","#f46d43", "#d73027","#a50026",] |
Faker.months | ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'] 即 ["{}月".format(i) for i in range(1, 13)] |
Faker.provinces | ["广东", "北京", "上海", "江西", "湖南", "浙江", "江苏"] |
Faker.guangdong_city | ["汕头市", "汕尾市", "揭阳市", "阳江市", "肇庆市", "广州市", "惠州市"] |
Faker.country | ['China', 'Canada', 'Brazil', 'Russia', 'United States', 'Africa', 'Germany'] |
Faker.days_attrs | ['0天','1天','2天','3天','4天','5天','6天', 即 ["{}天".format(i) for i in range(30)] |
Faker.days_values | [random.randint(1, 30) for _ in range(30)] |
3 Faker函数库的函数
3.1 choose
从以下几个中选一个返回
Faker.clothes,
Faker.drinks,
Faker.phones,
Faker.fruits,
Faker.animal,
Faker.dogs,
Faker.week,
3.2 values
直接贴官方文档对这个函数的描述吧:
@staticmethod
def values(start: int = 20, end: int = 150) -> list:
return [random.randint(start, end) for _ in range(7)]
以上是关于pyecharts应用3 Faker函数库的主要内容,如果未能解决你的问题,请参考以下文章