Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OptionError:'Pattern matched multiple keys' pandas

Tags:

python

pandas

xls

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'
like image 926
Samir Maharjan Avatar asked Feb 01 '26 07:02

Samir Maharjan


2 Answers

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 list of options in 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.

like image 52
Poe Dator Avatar answered Feb 02 '26 22:02

Poe Dator


In the new Pandas version, you need to use the code below to get the desired output.

pd.options.display.max_rows = 5
like image 23
sebastian Avatar answered Feb 02 '26 22:02

sebastian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!