Help needed! Constantly getting ValueError: Format specifier missing precision (original) (raw)
March 28, 2025, 12:23am 1
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
!pip install openpyxl
pd.options.display.float_format = ‘{:20..2f}’.format
from sklearn.cluster import KMeans
from sklearn.metrics import silhouette_score
from sklearn.preprocessing import StandardScaler
pd.set_option(‘display.max_columns’, 999)
df = pd.read_excel(“/Users/Anastasiia/Downloads/online_retail_II.xlsx”, sheet_name=0, engine=“openpyxl”)
df.head(10)
and after this I am getting error. An excel file was downloaded from public source https://archive.ics.uci.edu/dataset/502/online+retail+ii
I would be really glad if si=omebody could help me with this.
You have a typo.
It should be:
pd.options.display.float_format = '{:20.2f}'.format
The double period (..
) you had is invalid and so when you try to display the dataframe, you see the error about precision specifier missing.
Minor additional point:
Also, when you are running an install from inside an active notebook, you should be using %pip install
and not an exclamation point along with install commands anymore.
The magic pip command variation was added in 2019 to ensure the install occurs in the environment where the kernel is running that backs the active notebook.
The exclamation point doesn’t do that and can lead to issues. You should be also using %pip list
to see what is installed in the kernel environment that your notebook is using.
See more about the modern %pip install
command here. The second paragraph here goes into more details about why the exclamation point may lead to issues.
Thank you so much! I should have been more careful. Appreciate it!