'OptionError:'Pattern matched multiple keys' pandas

I am trying to read a excel file.

import requests
url = 'http://www.nepalstock.com/todaysprice/export'
r = requests.get(url, allow_redirects=True)
open('todayprice.xls', 'wb').write(r.content)

import pandas as pd
pd.set_option("xls", "openpyxl")
fileurl='todayprice.xls'
df=pd.read_excel(fileurl)
print(df)

I get an error saying:

raise OptionError("Pattern matched multiple keys")
pandas._config.config.OptionError: 'Pattern matched multiple keys'


Solution 1:[1]

This error often happens when people use older codes for pandas options, like precision. Starting in 1.4 some of these are replaced with longer forms, like display.precision.

Solution: visit pandas docs and find the updated name for your option.

I'd like to add that the error message Pattern matched multiple keys is quite confusing. Pandas team may want to change it.

Solution 2:[2]

You can try with the option io.excel.xls.reader instead of just xls.

From the doc:

Regexp which should match a single option. Note: partial matches are supported for convenience, but unless you use the full option name (e.g. x.y.z.option_name), your code may break in future versions if new options with similar names are introduced.

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
Solution 2