#100DaysOfCode in Python Transcripts
Chapter: Days 82-84: Data visualization with Plotly
Lecture: Concepts: what did we learn
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
Let's review what we've learned so far. Adding the RSS data, you really want to use feedparser to get the RSS data.
0:09
We pip install that as well as Plotly to do the data visualization. Then we imported the modules and I used feedparser to parse the RSS feed.
0:20
Which you can see one line of code and it wraps this in a nice data structure. Which you can even access with a dot notation. Then we prepare to data.
0:31
We wrote two helpers. One to convert the date string into datetime object. I made a little detour explaining a bit why you would want to use datetime
0:41
when you want to calculate the dates. But in this example, it was merely to extract year and month to have a consistent value for our graphs.
0:50
Then we extracted the categories from the blog links making them another helper. Using a regular expression to extract the category.
0:57
If it's in the dictionary, we return it, otherwise return to default set to article. Next we converted the data so far to usable structures.
1:07
All the graphs have counting in common and that's where counter is your best friend. You can see we generated a big list of all the publication dates
1:17
and we can just put them into counter which makes this nice, frequency counter. We prepare all three graphs. This was the first one.
1:28
The second one were the categories and the third one were the tags. You can already see that this starts to
1:35
paint a picture of what our PyBites blog is about. The final trick we needed was transposing the data, making X and Y axis.
1:44
I used a nice trick from Raymond Hettinger to use*data in combination with zip to make a date-like object or a list of tuples.
1:54
Transposing the data to X and Y axis' which made it way more easy to plot. Then I extenuate Plotly object, giving it the offline mode
2:07
and calling the innate notebook mode method to make it work inside my Jupyter notebook. Then the three plots.
2:15
Post for months frequency with all the prep data done, a small amount of code with a nice graph. Here you see the activity per month
2:23
and number of entries in the blog. Secondly, the common blog categories. We went and made a pie chart, which makes a nice visualization
2:31
what kind of categories our blog posts are. You can see that challenging articles trumped the other categories.
2:37
For common blog tags, it's kind of similar as categories but it's a bit more granular. There you can also see that we blogged quite a bit about
2:46
Flask and Django, github code automations, but this is a way nicer way to demonstrate it in any presentation. Check out other libraries, Bokeh,
2:58
this is from Panda's in combination with Matplotlib, a very powerful combination. This is a print screen from the Seaborn library.
3:10
As mentioned before, Matplotlib is also a very robust library and there might be many others but mostly I use Panda's and some Bokeh.
3:18
I decided to use Plotly for this lesson as it's simple to use and has nice graphs. Now it's your turn, keep calm and code in Python.