{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"provenance":[],"toc_visible":true,"authorship_tag":"ABX9TyOOuQeAbyAKGgICkuVFDhSA"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"}},"cells":[{"cell_type":"markdown","source":["# Ploting in Pandas\n","\n","Having to load data manually to build a visualization or plot gets cumbersome quickly. In many situations, we might want to work with data in a `pandas` `DataFrame` when building a visualization.\n","\n","The `pandas` `.plot()` attribute relies on the `matplotlib` API to generate plots, so our work with `matplotlib` will come in handy when we need to customize plots generated using `.plot()`. And in many cases, the `.plot()` syntax is similar to `matplotlib` `OO` syntax.\n","\n","We'll start by working with air quality data."],"metadata":{"id":"dZw_mWFU9Y7D"}},{"cell_type":"markdown","source":["## `.plot()`\n","\n","We can do a quick visual check of the data by passing the entire `DataFrame` to `.plot()`."],"metadata":{"id":"PorDWuNH9-sk"}},{"cell_type":"code","source":["import pandas as pd # import statements\n","df = pd.read_csv('https://raw.githubusercontent.com/kwaldenphd/elements-of-computing/main/book/data/ch10/air_quality_no2.csv', index_col=0, parse_dates=True) # load data\n","df # show output"],"metadata":{"id":"xJ9bgcWRyrVZ","colab":{"base_uri":"https://localhost:8080/","height":455},"executionInfo":{"status":"ok","timestamp":1706141936498,"user_tz":300,"elapsed":190,"user":{"displayName":"Katherine Walden","userId":"17094108395123900917"}},"outputId":"d31d24d1-5fc8-4f36-835a-fab7e641abd6"},"execution_count":null,"outputs":[{"output_type":"execute_result","data":{"text/plain":[" station_antwerp station_paris station_london\n","datetime \n","2019-05-07 02:00:00 NaN NaN 23.0\n","2019-05-07 03:00:00 50.5 25.0 19.0\n","2019-05-07 04:00:00 45.0 27.7 19.0\n","2019-05-07 05:00:00 NaN 50.4 16.0\n","2019-05-07 06:00:00 NaN 61.9 NaN\n","... ... ... ...\n","2019-06-20 22:00:00 NaN 21.4 NaN\n","2019-06-20 23:00:00 NaN 24.9 NaN\n","2019-06-21 00:00:00 NaN 26.5 NaN\n","2019-06-21 01:00:00 NaN 21.8 NaN\n","2019-06-21 02:00:00 NaN 20.0 NaN\n","\n","[1035 rows x 3 columns]"],"text/html":["\n","
\n"," | station_antwerp | \n","station_paris | \n","station_london | \n","
---|---|---|---|
datetime | \n","\n"," | \n"," | \n"," |
2019-05-07 02:00:00 | \n","NaN | \n","NaN | \n","23.0 | \n","
2019-05-07 03:00:00 | \n","50.5 | \n","25.0 | \n","19.0 | \n","
2019-05-07 04:00:00 | \n","45.0 | \n","27.7 | \n","19.0 | \n","
2019-05-07 05:00:00 | \n","NaN | \n","50.4 | \n","16.0 | \n","
2019-05-07 06:00:00 | \n","NaN | \n","61.9 | \n","NaN | \n","
... | \n","... | \n","... | \n","... | \n","
2019-06-20 22:00:00 | \n","NaN | \n","21.4 | \n","NaN | \n","
2019-06-20 23:00:00 | \n","NaN | \n","24.9 | \n","NaN | \n","
2019-06-21 00:00:00 | \n","NaN | \n","26.5 | \n","NaN | \n","
2019-06-21 01:00:00 | \n","NaN | \n","21.8 | \n","NaN | \n","
2019-06-21 02:00:00 | \n","NaN | \n","20.0 | \n","NaN | \n","
1035 rows × 3 columns
\n","