Today I learned a lot in Python
Get current directory
Reading CSVs in Python
Counting in Python
Using Counter to create a list of unique items and counts by appending items to the lists:
Ordering lists with a lambda expression
According to Eric Davis the lambda expression is a good way to make quick expressions on the fly for organizing things like the Counter lists:
Plotting with Python
Given that the lists
count are built above by the
Counter(), you can pass them to matplotlib for charting:
- If you don’t want to save the images, you could just show them instead with
plt.clf() clears the figure so you can plot something else on it. Otherwise you’d need to close it before continuing.
plt.close() can do that.
Depending on the source CSV, the above creates these two charts:
View more TIL posts