In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
How to use Python to help friends make a pork data analysis chart, in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
Here's what happened:
Looking up, the second brother raised the price again.
Sighed, if it goes on like this, I really can't afford to eat pancakes with meat.
Ordered two pancakes and a bowl of wonton.
Dong is my classmate in junior high school. I haven't been in touch for a few days.
Watching him almost talk about the block chain, although this is unreliable, but still promised Adong to help him with the map.
Get to work!
Dong wants a picture like this:
Line chart, let's get the data first.
Open the official website, find and jump to the pig price website http://zhujia.zhuwang.cc/
F12recoveryNetwork looks at the asynchronous request XHR and successfully finds the price API.
A new tab opens to parse Json data online.
Part of the crawler code (see the download address at the end of the article for the complete code):
Def get_comments (url): doc = get_json (url) dic = {} dic ['pigprice'] = doc [' pigprice'] dic ['pig_in'] = doc [' pig_in'] dic ['pig_local'] = doc [' pig_local'] dic ['maizeprice'] = doc [' maizeprice'] dic ['bean'] = doc [' bean'] a ='- '.join (doc [' Time'] [3]) b = time.strftime ('% Ymuri% mmury% d' Time.localtime (time.time ()) print (dateRange (a)) dic ['time'] = dateRange (a) return pd.DataFrame (dic) data = get_comments (' http://zhujia.zhuwang.cc/index/api/chartData?areaId=-1&aa=1571997555296'))
Running result:
Successfully obtained various price √ in the last year
Let's start making a line chart for Adong:
For the price of live pigs, just choose the first extra three yuan.
It is easy to make a line chart with matplotlib.
From pylab import mpl import matplotlib.pyplot as plt mpl.rcParams ['font.sans-serif'] = [' SimHei'] # specifies the default font mpl.rcParams ['axes.unicode_minus'] plt.figure (figsize= (8data 4), dpi=80) plt.plot (data [' time'], data ['pigprice'], color= "r", linestyle = "-") plt.xticks (data [' time'] [2SimHei'], rotation=0) plt.xlabel ("live pig (outer ternary) yuan / kg")
In addition, now that we have obtained the price of corn and soybean meal, let's do it together.
Multiple sub-graphs can be drawn with plt.subplot.
From pylab import mpl import matplotlib.pyplot as plt mpl.rcParams ['font.sans-serif'] = [' SimHei'] # specifies the default font mpl.rcParams ['axes.unicode_minus'] plt.figure (figsize= (8jing10), dpi=80) plt.figure (1) ax1 = plt.subplot (311) plt.plot (data [' time'], data ['pigprice'], color= "r", linestyle = "-") plt.xticks ([]) plt.annotate (data [' pigprice'] [365] Xy= (data ['time'] [365], 40), xytext= (data [' time'] [270,35), arrowprops=dict (facecolor='black', shrink=0.1, width=0.5)) plt.xlabel ("live pig (outer ternary) yuan / kg") ax2 = plt.subplot (312) plt.plot (data ['time'], data [' maizeprice'], color= "y" Linestyle = "-") plt.xticks ([]) plt.xlabel ("corn (15% moisture) yuan / ton") ax3 = plt.subplot (313) plt.plot (data ['time'], data [' bean'], color= "g", linestyle = "-") plt.xlabel ("soybean meal (43% protein) yuan / ton") plt.xticks (data ['time'] [2VRV 121], rotation=0)
Finish the job
Send it to Dong.
Only to get such a reply.
That's how he defines a friend in his mind.
Sure,
This is very East Brother.
It's brotherly.
This is the answer to the question about how to use Python to help friends make a pork data analysis chart. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.