CST383 - Week 3
CST383 - Week 3
This week we learned more about how to work in Colab/Jupyter notebook. I personally used Jupyter because I thought self-hosted material is more appropriate for my use case. I think this notebook style of coding is very useful, because I can test only a single block of code at a time rather than the full file.
We started to learn how to code Pyplot visualizations of data, which is very nice. I am a visual learner so these exercises were very helpful for me to understand these concepts better. I didn't have much difficulty understanding these concepts to complete the homework, though I know I will need to read further into graphing two continuous variables in the coming weeks. A few things stood out to me to remember:
- Use a semicolon ( ; ) after the last plotting statement or use plt.show() at the end of the code block to prevent matplotlib from automatically adding text before a graph.
- Use plt.xlabel() or plt.ylabel() to label the x or y axis. For box plots, the x axis is automatically set as the variable name - use plt.xticks([]) to empty it. plt.xticks(['a','b','c']) will add 3 increment labels 'a', 'b', 'c' to the x axis. plt.xlabel() will add a label below the x-ticks on the x axis.
- You can use f"{x:.2f}" to format a number x to 2 decimal places.
- To include a number in a range, for example df['column1'].plot.hist(bins=range(10,111,10)) this starts at 10 and evenly spaces out 10 width bins (third number in range()), up to 110 (second number in range() is not inclusive, so we must add 1 to include 110).
Comments
Post a Comment