In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how Python makes a beautiful dynamic chart". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to make a beautiful dynamic chart by Python".
Preface
The following dynamic visual map is drawn by Brother J himself, showing the distribution and changes of goods purchased by Guangzhou enterprises and institutions in the online mall over a period of time.
Next, hand-in-hand will teach you how to draw this dynamic diagram, you can reply "kepler" in the official account background to get the data set for testing.
Data preparation
The first step is to open and preview the dataset, with a total of 766 purchase records, including three fields: purchase time, purchase unit and purchase amount.
1df = pd.read_excel ('cc.xls',index=False) 2df.head ()
The second step is to obtain longitude and latitude according to the purchasing unit field. There are many ways to obtain longitude and latitude in batches. For more information, please refer to "using Python to evaluate three methods of batch query longitude and latitude. Which one do you pick?" ".
1def gaode (addr): 2 para = {3 'key':' your', 4 'address':addr 5} 6 url =' https://restapi.amap.com/v3/geocode/geo?' 7 req = requests.get (url) Para) 8 req = req.json () 9 print ('-'* 30) 10 if req ['status'] = = 11 if len (req [' geocodes']) > 0:12 m = req ['geocodes'] [0] [' location'] 13 print (m) 14 else:15 print ("None") 16 M = "" 17 else:18 print ("None") 1920 return m21gaode (addr= "Guangzhou")
Apply the above functions and preview the data
1df ['lat_lon'] = df [' buyer'] .apply (gaode) 2df.head ()
The third step is to sort and store the latitude and longitude fields in csv format.
1df ["lat"] = df ["lat_lon"] .str.split (',', expand=True) [1] 2df ["lon"] = df ["lat_lon"] .str.split (',', expand=True) [0] 3df = df.drop ('lat_lon',axis=1) 4df.to_csv (' cc.csv',index=False)
After adding the data, you can set the icon color, size, map style and other parameters according to your preferences.
1. Icon settin
3. Add a city outline
City profile data can be obtained on the DATAV.GeoAtlas website.
5. Add Timeline
OK, it's done!
Thank you for your reading, the above is the content of "how Python makes beautiful dynamic charts". After the study of this article, I believe you have a deeper understanding of how Python makes beautiful dynamic charts, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.