t Import CSV, select and plot in Python
Most of you may be using visual code for coding with Python, how ever if instead of typing the .py, you type .ipynb you can have python with jupyter notebooks in your Visual Code without having to install Anaconda. Once you installed properly the jupyter notebook extension we can start importing the CSV file for all the data scientist out there. Note that in this example i import pandas and matplotlib, in you have never work with these you will need to install them with the famous “pip install”. As it is shown in the number 1.
For import the data you need to copy the next function and change only the location of your .csv as it is show, and one way to see if it was properly imported is with the function Print. As it is shown in the number 2.
There are many ways to see the data how ever we are going to use the 3 basics. “.head(x)” for showing only the x number of first rows, then we have the “.shape”, to see how many columns and rows does our dataset has. Finally we have “.describe()” to display the summary statistics of the DataFrame.
Then we have the selection by label with .loc and select of position with .iloc. If you want to select a column, first you need to set the column as an index, then the “.loc” acces to specific dates and finally print the certain date.
Get Handy Sherlyn Dueñas Gómez’s stories in your inbox
Join Medium for free to get updates from this writer.
The main difference between .loc and .iloc is that in the second one you will print the first column with 1 and the last one with -1.
For plot the Data frame of certain years we will need the .loc doe we did, and add the plot.show function as it is shown. In this example i change the dates, to plot from the 2016 year to the 2021 year, just the close stock.









