The column is sorted the first 5 values are plotted on a bar graph Top5 = df.sort_values(by=,ascending = False)Īx = sns.barplot(x = colName, y = "title", data = top5) Since we will be doing it for multiple columns, we will write a function that will accept the column name as a parameter and return a figure. We can use Pandas’ sum() function to find the sum of a column and use the standard len() function to find the number of rows (articles) in our dataframe. Our Summary section will basically consist of the sum of the various features in our dataframe and the average. Now, we will display a title and the dataframe in the UI st.title("Medium Stats") We will use pandas’ read_json() function to convert the JSON file to a dataframe. Run the streamlit app to ensure everything is working fin streamlit run main.pyĭisplaying DataFrame of Medium Stats Screenshot by Authorīefore we begin, we will set the default theme to dark mode and the layout to wide mode.Import the Libraries import pandas as pd.
Python download json install#
Python download json how to#
How to use the browser console to scrape and save data in a file with JavaScriptĪ while back I had to crawl a site for links, and further use those page links to crawl data using selenium or… We will need to use the script I provided earlier. The following article talks about downloading your Medium Stories. Run the script in your console and it will download a JSON file with all your stats. The JSON file will basically be an array of objects having the above properties.īasically, we will have to go to and scroll all the way to the bottom, i.e scroll till you see all your articles. Publication the article was published in.However, if you want more metrics/stats about your articles, you will have to tinker around with the script. You don’t need to know JavaScript, you can run the script as-is. Check this article to see how you can access your browser’s console. We will essentially be scraping the stats, we will have to do it using JavaScript since it will have to run in your browser’s console. Unfortunately Medium doesn’t seem to have any easy-to-use API publicly available so we will have to use a slightly hacky solution. You can find the repo here Getting Medium Stats in a JSON format Display the charts on a UI created using Streamlit.Use Pandas and Plotting libraries to plot charts.How to get a JSON file of your Medium Stats and create a Dashboard using Streamlit