Noob attempts Python to Data Vis
I made a post that looks at Singapore’s recycling trends using a graph I did up via Python:
With patience and grit to make sense of the language, it feels encouraging to be able to churn out something so simple-looking using Python —never mind the fact that this could have also been easily replicated on Tableau or Excel.
To get started, I made use of a simple and small dataset that I could work with. I added extra columns to input more meaningful indicators out of the raw data provided: ratio and difference.
In order to read the file, my file had to be saved in CSV format (.csv). The dataset also has to be saved in the same location ie. same folder with your Python notebook file.
With that aside, we can then start playing with our Jupyter notebook file. We can start with importing the following modules to produce a DataFrame of our data set which will enable us to plot it out.
What you see above is the Data Frame of your data set. This was made possible by the modules imported that codes for this. We can then go on to actualise our data visualisation in the next cell.
What ‘seaborn’ does is to provide a grid backdrop to your graph for better visibility. You can use this if you want to better identify turning points. Other than that, you can omit it too.
What the code above does is to account for two y-axes: our waste-to-recycled ratio and our improvement rate.
Once you run these cells, the above graph will show and voila!
I do note that this simple visualisation is just scratching the surface of Python. It meant that I had to compromise on ambitious, elaborate visuals just so I could get the hang of the basics first. This might thus be useful for those who need the right prodding as to where to get started with data visualisation using Python.
Hope this is of some use. Cheers!