I'm getting a ParserError
when I try to read a csv file directly from github:
import pandas as pd
url = 'https://github.com/marcopeix/AppliedTimeSeriesAnalysisWithPython/tree/main/data/jj.csv'
df = pd.read_csv(url)
ParserError: Error tokenizing data. C error: Expected 1 fields in line 41, saw 29
but if I download the file and read it from disk, it works without issues:
df = pd.read_csv('/home/data/jj.csv')
Your page is not linking to the raw CSV file but to a HTML page
You should use the raw URL:
url = 'https://raw.githubusercontent.com/marcopeix/AppliedTimeSeriesAnalysisWithPython/refs/heads/main/data/jj.csv'
df = pd.read_csv(url)
print(df.head())
Output:
date data
0 1960-01-01 0.71
1 1960-04-01 0.63
2 1960-07-02 0.85
3 1960-10-01 0.44
4 1961-01-01 0.61
You can find the link here: