Menu Close

How to use Python Pandas read_csv with a URL?

Sometimes, we want to use Python Pandas read_csv with a URL.

In this article, we’ll look at how to use Python Pandas read_csv with a URL.

How to use Python Pandas read_csv with a URL?

To use Python Pandas read_csv with a URL, we just call read_csv with the URL of the CSV.

For instance, we write

import pandas as pd

url="https://raw.githubusercontent.com/cs109/2014_data/master/countries.csv"
c=pd.read_csv(url)

to call read_csv with the url of the CSV and assign the returned data frame to c.

Conclusion

To use Python Pandas read_csv with a URL, we just call read_csv with the URL of the CSV.

Posted in Python, Python Answers