'Can't read data with read_html

I can't manage to import the data for pandas.

here the code:

import pandas as pd


tables = pd.read_html('https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-states.csv')
table = tables[1]

print(table)


Solution 1:[1]

You can simply get the data using read_csv:

import pandas as pd
tables = pd.read_csv('https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-states.csv')
tables

which results in:

date state fips cases deaths
0 2020-01-21 Washington 53 1 0
1 2020-01-22 Washington 53 1 0
2 2020-01-23 Washington 53 1 0
3 2020-01-24 Illinois 17 1 0
4 2020-01-24 Washington 53 1 0

Note that, if you are trying to show the dataframe using a notebook(Kernel) you can use display on the dataframe in form of display(tables), otherwise print works fine.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Amirhossein Kiani