Loading a CSV Dataset From a URL
Learn to import a CSV dataset from a URL.
We'll cover the following...
Loading CSV files
The CSV format is popular for storing and transferring data. Files with a .csv extension are plain text files containing data records with comma-separated values.
Let’s see how we can analyze data from a CSV file using Python by loading the file from a URL.
Python 3.8
import pandas as pddf = pd.read_csv('https://raw.githubusercontent.com/CourseMaterial/DataWrangling/main/flowerdataset.csv')print(df.head())
Let’s review the code line by line:
Line 1: We start by first importing the pandas library using
import pandas as pd.Line 2: We pass the URL of the dataset, enclosed in quotes, to the
read_csv()function and save the result in thedfvariable.
Note: When we save the dataset inside a variable, we refer to the variable as a DataFrame. A DataFrame is a tabular data structure that contains data represented in rows and columns. ...