Skip to content

Commit 977eae3

Browse files
naomi172839datapythonista
authored andcommitted
STYLE: Using f-strings in pandas/__init__.py (#30475)
1 parent cde73af commit 977eae3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

pandas/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
try:
1111
__import__(dependency)
1212
except ImportError as e:
13-
missing_dependencies.append("{0}: {1}".format(dependency, str(e)))
13+
missing_dependencies.append(f"{dependency}: {e}")
1414

1515
if missing_dependencies:
1616
raise ImportError(
@@ -33,10 +33,10 @@
3333
# hack but overkill to use re
3434
module = str(e).replace("cannot import name ", "")
3535
raise ImportError(
36-
"C extension: {0} not built. If you want to import "
36+
f"C extension: {module} not built. If you want to import "
3737
"pandas from the source directory, you may need to run "
3838
"'python setup.py build_ext --inplace --force' to build "
39-
"the C extensions first.".format(module)
39+
"the C extensions first."
4040
)
4141

4242
from datetime import datetime
@@ -213,16 +213,16 @@ class Panel:
213213
return Panel
214214
elif name in {"SparseSeries", "SparseDataFrame"}:
215215
warnings.warn(
216-
"The {} class is removed from pandas. Accessing it from "
216+
f"The {name} class is removed from pandas. Accessing it from "
217217
"the top-level namespace will also be removed in the next "
218-
"version".format(name),
218+
"version",
219219
FutureWarning,
220220
stacklevel=2,
221221
)
222222

223223
return type(name, (), {})
224224

225-
raise AttributeError("module 'pandas' has no attribute '{}'".format(name))
225+
raise AttributeError(f"module 'pandas' has no attribute '{name}'")
226226

227227

228228
else:

0 commit comments

Comments
 (0)