Skip to content

Commit dc25705

Browse files
committed
Update concat.py
All changes made for concat.py + black pandas formatting.
1 parent 863fb52 commit dc25705

File tree

1 file changed

+13
-26
lines changed

1 file changed

+13
-26
lines changed

pandas/core/reshape/concat.py

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,9 @@ def __init__(
277277
):
278278
if isinstance(objs, (NDFrame, str)):
279279
raise TypeError(
280-
"first argument must be an iterable of pandas "
281-
"objects, you passed an object of type "
282-
'"{name}"'.format(name=type(objs).__name__)
280+
f"first argument must be an iterable of pandas "
281+
f"objects, you passed an object of type "
282+
f'"{type(objs).__name__}"'
283283
)
284284

285285
if join == "outer":
@@ -324,8 +324,8 @@ def __init__(
324324
for obj in objs:
325325
if not isinstance(obj, (Series, DataFrame)):
326326
msg = (
327-
"cannot concatenate object of type '{typ}';"
328-
" only Series and DataFrame objs are valid".format(typ=type(obj))
327+
f"cannot concatenate object of type '{type(obj)}';"
328+
" only Series and DataFrame objs are valid"
329329
)
330330
raise TypeError(msg)
331331

@@ -375,8 +375,7 @@ def __init__(
375375
self._is_series = isinstance(sample, Series)
376376
if not 0 <= axis <= sample.ndim:
377377
raise AssertionError(
378-
"axis must be between 0 and {ndim}, input was"
379-
" {axis}".format(ndim=sample.ndim, axis=axis)
378+
f"axis must be between 0 and {sample.ndim}, input was" f" {axis}"
380379
)
381380

382381
# if we have mixed ndims, then convert to highest ndim
@@ -506,8 +505,7 @@ def _get_new_axes(self):
506505

507506
if len(self.join_axes) != ndim - 1:
508507
raise AssertionError(
509-
"length of join_axes must be equal "
510-
"to {length}".format(length=ndim - 1)
508+
f"length of join_axes must be equal " f"to {ndim - 1}"
511509
)
512510

513511
# ufff...
@@ -528,7 +526,7 @@ def _get_comb_axis(self, i):
528526
)
529527
except IndexError:
530528
types = [type(x).__name__ for x in self.objs]
531-
raise TypeError("Cannot concatenate list of {types}".format(types=types))
529+
raise TypeError(f"Cannot concatenate list of {types}")
532530

533531
def _get_concat_axis(self):
534532
"""
@@ -547,8 +545,8 @@ def _get_concat_axis(self):
547545
for i, x in enumerate(self.objs):
548546
if not isinstance(x, Series):
549547
raise TypeError(
550-
"Cannot concatenate type 'Series' "
551-
"with object of type {type!r}".format(type=type(x).__name__)
548+
f"Cannot concatenate type 'Series' "
549+
f"with object of type {type(x).__name__!r}"
552550
)
553551
if x.name is not None:
554552
names[i] = x.name
@@ -584,10 +582,7 @@ def _maybe_check_integrity(self, concat_index: Index):
584582
if self.verify_integrity:
585583
if not concat_index.is_unique:
586584
overlap = concat_index[concat_index.duplicated()].unique()
587-
raise ValueError(
588-
"Indexes have overlapping values: "
589-
"{overlap!s}".format(overlap=overlap)
590-
)
585+
raise ValueError(f"Indexes have overlapping values: " f"{overlap!s}")
591586

592587

593588
def _concat_indexes(indexes) -> Index:
@@ -629,11 +624,7 @@ def _make_concat_multiindex(indexes, keys, levels=None, names=None) -> MultiInde
629624
try:
630625
i = level.get_loc(key)
631626
except KeyError:
632-
raise ValueError(
633-
"Key {key!s} not in level {level!s}".format(
634-
key=key, level=level
635-
)
636-
)
627+
raise ValueError(f"Key {key!s} not in level {level!s}")
637628

638629
to_concat.append(np.repeat(i, len(index)))
639630
codes_list.append(np.concatenate(to_concat))
@@ -685,11 +676,7 @@ def _make_concat_multiindex(indexes, keys, levels=None, names=None) -> MultiInde
685676

686677
mask = mapped == -1
687678
if mask.any():
688-
raise ValueError(
689-
"Values not found in passed level: {hlevel!s}".format(
690-
hlevel=hlevel[mask]
691-
)
692-
)
679+
raise ValueError(f"Values not found in passed level: {hlevel[mask]!s}")
693680

694681
new_codes.append(np.repeat(mapped, n))
695682

0 commit comments

Comments
 (0)