In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to use Python to make a visual travel strategy". In daily operation, I believe many people have doubts about how to use Python to make a visual travel strategy. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the questions of "how to use Python to make a visual travel strategy". Next, please follow the editor to study!
Data preprocessing
For the obtained data, we need to carry out further processing to meet the needs of the analysis. Our main data processing steps are as follows:
Delete duplicate valu
Correction field
Delete unwanted fields
Specific code implementation
# data reading import pandas as pdimport re# data reading base_data = pd.read_excel ('trip_data_merge.xlsx') # deleting duplicate values base_data.drop_duplicates (inplace=True) # unneeded fields base_data = base_data.drop ([' link'], axis=1) # field correction It is convenient to count base_data ['days'] = base_data ['days'] .apply (lambda x: re.sub ("\ D", "", x)) base_data ['photos'] = base_data ['photos'] .apply (lambda x: re.sub ("\ D", ", x)) base_data ['fee'] = base_data ['fee'] .apply (lambda x: re.sub ("\ D ",") Str (x)) base_data ['fee'] = base_data ['fee'] .apply (lambda x: eval (x) if len (x) > 0 else 0) base_data ['date'] = base_data [' departure date'] .apply (lambda x: x.split () [0]) base_data ['date_year'] = base_data [' departure date']. Apply (lambda x: x.split () [0]] [ 4]) base_data ['readings'] = base_data ['readings'] .apply (lambda x: int (re.sub ("\ D") ", str (x)) * 10000 if str (x) .find ('ten thousand') else x) data analysis and visualization
Cost problem
When you travel, you should first consider the affirmative cost. Due to the epidemic, in the cost data analysis statistics, we excluded the data for 2020 and considered the data for 2017, 2018 and 2019.
Distribution of tourists in Shanghai
Long stay of Maldivian tourists
Core code presentation
# percentage of Shanghai tourists' stay from pyecharts import options as optsfrom pyecharts.charts import Piefrom pyecharts.faker import Fakerc = (Pie () .add ("", [list (z) for z in zip (list (base_data_city_day_sh ['days]), list (base_data_city_day_sh [' num']))], radius= ["40%", "55%"] Label_opts=opts.LabelOpts (position= "outside", formatter= "{a | {a}} {abg |}\ n {hr |}\ n {b | {b}:} {c} {per | {d}%}", background_color= "# eee", border_color= "# aaa", border_width=1, border_radius=4 Rich= {"a": {"color": "# 999", "lineHeight": 22, "align": "center"}, "abg": {"backgroundColor": "# e3e3e3", "width": "100%", "align": "right" "height": 22, "borderRadius": [4,4,0,0],}, "hr": {"borderColor": "# aaa", "width": "100%", "borderWidth": 0.5 "height": 0,}, "b": {"fontSize": 16, "lineHeight": 33}, "per": {"color": "# eee", "backgroundColor": "# 334455", "padding": [2,4] "borderRadius": 2,},},), .set _ global_opts (title_opts=opts.TitleOpts (title= "Shanghai tourist stay percentage") .render ("Shanghai tourist stay ratio .html"))
Word cloud picture
Import stylecloudfrom IPython.display import Image # is used to display the local picture in jupyter lab result_gap = '.join (result) # draw the word stylecloud.gen_stylecloud (text=result_gap, max_words=1000, collocations=False, font_path=r'msyh.ttf', icon_name='fas fa-plane-departure') Size=624, output_name=' sign-in word cloud map. PNG') Image (filename=' sign-in word cloud picture. PNG') here The study on "how to make a visual travel guide with Python" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.