In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use the Python visualization library Pandas_Alive". The content of 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 use the Python visualization library Pandas_Alive.
Preface
Recently, it has been found that a similar visual library "Pandas_Alive" in Chinese can not only contain dynamic bar charts, but also draw dynamic curve products, bubble charts, pie charts, maps and so on.
It also takes a few lines of code to replace the dynamic chart.
GitHub address:
Https://github.com/JackMcKew/pandas_alive
Working with documentation:
Https://jackmckew.github.io/pandas_alive/
The recommended installation version is 0.2.3 and the matplotlib version is 3.2.1.
At the same time, you need to install tqdm (display progress bar) and descartes (place map-related libraries).
Otherwise, there will be an error, and it is estimated that the author's requestment.txt does not include these two libraries.
Well, after a successful installation, you can date this third-party library and directly choose to load the local file.
Import pandas_alive as pd import pandas covid_df = pd.read_csv ('data / covid19.csv',index_col = 0pm parseurs = [0]) covid_df.plot_animated (filename =' examples / example-barh-chart.gif',n_visible = 15)
When you start to learn the library, you can reduce the data, so that the time to generate GIF will be faster.
For example, in the following practice, basically only about 20 days of data are selected.
For other diagrams, we can check the API description of the official document to understand.
Let's take a look at other replacement methods for dynamic charts.
Dynamic bar graph elec_df = pd.read_csv ("data / Aus_Elec_Gen_1980_2018.csv", index_col = 0pm parseurs = [0], thousands of yuan =',') elec_df = elec_df.iloc [: 20 example-electricity- generation:] elec_df.fillna (0). Plot_animated ('examples / example-electricity- generation-australia.gif',period_fmt = "% Y", title =' Australian Power Source for 1980-2018')
02 dynamic bar chart
Covid_df = pd.read_csv ('data / covid19.csv',index_col = 0Magnum parseurs = [0]) covid_df.plot_animated (filename =' examples / example-barv-chart.gif', direction = 'vaulting pencils _ visible = 15)
03 dynamic graph
Covid_df = pd.read_csv ('data / covid19.csv',index_col = 0 data parseurs = [0]) covid_df.diff () fillna (0). Plot_animated (filename =' examples / example-line-chart.gif',kind = 'line',period_label = {' x: 0.25,0.9})
04 dynamic area map
Covid_df = pd.read_csv ('data / covid19.csv',index_col = 0Magnum parseurs = [0]) covid_df.sum (axis = 1) .fillna (0). Plot_animated (filename =' examples / example-bar-chart. Gif', kind = 'bar', period_label = {' x: 0.1,0.1,0.9}, enable_progress_bar = True,steps_per_period = 2 Period_length = 200)
05 dynamic scatter plot
Max_temp_df = pd.read_csv ("data / Newcastle_Australia_Max_Temps.csv", parse_dates = {"Timestamp": ["Year", "Month", "Day"]},) min_temp_df = pd.read_csv ("data / Newcastle_Tustralia_T. , parse_dates = {"Timestamp": ["Year", "Month", "Day"]},) max_temp_df = max_temp_df.iloc [: 5000 merged_temp_df:] min_temp_df = min_temp_df.iloc [: 5000 merged_temp_df:] pd. Merge_asof (max_temp_df,min_temp_df,on = "Timestamp") merged_temp_df.index = pd.to_datetime (merged_temp_df ["Timestamp"] .dt.strftime ('% Y /% m /% d')) keep_columns = ["lowest temperature (degrees Celsius)", "maximum temperature (degrees Celsius)"merged_temp_df [keep_columns] .resample (" Y "). Mean (). Plot_animated (filename = 'examples / example-scatter-chart.gif',kind = "scatter", title = "maximum and minimum temperature Newcastle, Australia")
06 dynamic pie chart
Covid_df = pd.read_csv ('data / covid19.csv',index_col = 0Magnum parseurs = [0]) covid_df.plot_animated (filename =' examples / example-pie-chart.gif',kind = "pie", rotationlabels = True,period_label = {'x cards: 0,'y stories: 0})
07 dynamic bubble chart
Multi_index_df = pd.read_csv ("data / multi.csv", title = [0,1], index_col = 0) multi_index_df.index = pd.to_datetime (multi_index_df.index,dayfirst = true) map_chart = multi_index_df.plot_animated (category = "bubble", file name = "examples / example-bubble-chart.gif", x_data_label = "longitude", y_data_label = "latitude" Size_data_label = "case", color_data_label = "case", vmax = 5 stepsperfect perennial period = 3) True,period_length = 500, dpi = 100)
08 geospatial point chart
Import geopandas Import pandas_alive Import contextily GDF = geopandas.read_file ('data / NSW-covid19- case by postcode.gpkg') gdf.index = gdf.postcode GDF = gdf.drop (' zip code', axis = 1) result = gdf.iloc [: 20] result ['geometry'] = gdf.iloc [:,-1:] [' geometry'] map_chart = result.plot_animated (filename = 'examples / example-geo-point-chart .gif " Basemap_format = {'source':contextily.providers.Stamen.Terrain})
09 general geographical chart
Import geopandas Import pandas_alive Import contextily GDF = geopandas.read_file ('data / Italy-covid-region.gpkg') gdf.index = gdf.region GDF = gdf.drop (' region', axis = 1) result = gdf.iloc [: 20] result ['geometry'] = gdf.iloc [:,-1:] [' geometry'] map_chart = result.plot_animated (filename = 'examples / example-example-example-geo-polygon-chart.gif' Basemap_format = {'source':contextily.providers.Stamen.Terrain})
Thank you for reading, the above is the content of "how to use Python visualization library Pandas_Alive". After the study of this article, I believe you have a deeper understanding of how to use Python visualization library Pandas_Alive, 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.