Skip to content

STY: Spaces over concat strings - batch 1 #30707

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pandas/_libs/tslib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ def ints_to_pydatetime(const int64_t[:] arr, object tz=None, object freq=None,
elif box == "datetime":
func_create = create_datetime_from_ts
else:
raise ValueError("box must be one of 'datetime', 'date', 'time' or"
" 'timestamp'")
raise ValueError("box must be one of 'datetime', 'date', 'time' or 'timestamp'")

if is_utc(tz) or tz is None:
for i in range(n):
Expand Down
4 changes: 2 additions & 2 deletions pandas/_libs/tslibs/strptime.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ def array_strptime(object[:] values, object fmt,
"the ISO year directive '%G' and a weekday "
"directive '%A', '%a', '%w', or '%u'.")
else:
raise ValueError("ISO week directive '%V' is incompatible with"
" the year directive '%Y'. Use the ISO year "
raise ValueError("ISO week directive '%V' is incompatible with "
"the year directive '%Y'. Use the ISO year "
"'%G' instead.")

# If we know the wk of the year and what day of that wk, we can figure
Expand Down
6 changes: 3 additions & 3 deletions pandas/_libs/tslibs/timestamps.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -814,9 +814,9 @@ default 'raise'
'shift_backward')
if nonexistent not in nonexistent_options and not isinstance(
nonexistent, timedelta):
raise ValueError("The nonexistent argument must be one of 'raise',"
" 'NaT', 'shift_forward', 'shift_backward' or"
" a timedelta object")
raise ValueError("The nonexistent argument must be one of 'raise', "
"'NaT', 'shift_forward', 'shift_backward' or "
"a timedelta object")

if self.tzinfo is None:
# tz naive, localize
Expand Down
3 changes: 1 addition & 2 deletions pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,7 @@ def __init__(self, values, dtype=_NS_DTYPE, freq=None, copy=False):
if not isinstance(values, np.ndarray):
msg = (
f"Unexpected type '{type(values).__name__}'. 'values' must be "
"a DatetimeArray ndarray, or Series or Index containing one of"
" those."
"a DatetimeArray ndarray, or Series or Index containing one of those."
)
raise ValueError(msg)
if values.ndim not in [1, 2]:
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/arrays/timedeltas.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ def __init__(self, values, dtype=_TD_DTYPE, freq=None, copy=False):

if not isinstance(values, np.ndarray):
msg = (
f"Unexpected type '{type(values).__name__}'. 'values' must be a"
" TimedeltaArray ndarray, or Series or Index containing one of those."
f"Unexpected type '{type(values).__name__}'. 'values' must be a "
"TimedeltaArray ndarray, or Series or Index containing one of those."
)
raise ValueError(msg)
if values.ndim not in [1, 2]:
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/computation/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,8 @@ def eval(
if parsed_expr.assigner is None:
if multi_line:
raise ValueError(
"Multi-line expressions are only valid"
" if all expressions contain an assignment"
"Multi-line expressions are only valid "
"if all expressions contain an assignment"
)
elif inplace:
raise ValueError("Cannot operate inplace if there is no assignment")
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -7000,8 +7000,8 @@ def append(self, other, ignore_index=False, verify_integrity=False, sort=False):
other = Series(other)
if other.name is None and not ignore_index:
raise TypeError(
"Can only append a Series if ignore_index=True"
" or if the Series has a name"
"Can only append a Series if ignore_index=True "
"or if the Series has a name"
)

index = Index([other.name], name=self.index.name)
Expand Down
9 changes: 4 additions & 5 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -6428,8 +6428,8 @@ def replace(
if not is_dict_like(to_replace):
if not is_dict_like(regex):
raise TypeError(
'If "to_replace" and "value" are both None'
' and "to_replace" is not a list, then '
'If "to_replace" and "value" are both None '
'and "to_replace" is not a list, then '
"regex must be a mapping"
)
to_replace = regex
Expand All @@ -6443,9 +6443,8 @@ def replace(
if any(are_mappings):
if not all(are_mappings):
raise TypeError(
"If a nested mapping is passed, all values"
" of the top level mapping must be "
"mappings"
"If a nested mapping is passed, all values "
"of the top level mapping must be mappings"
)
# passed a nested dict/Series
to_rep_dict = {}
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/groupby/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,8 @@ def get_converter(s):
except KeyError:
# turns out it wasn't a tuple
msg = (
"must supply a same-length tuple to get_group"
" with multiple grouping keys"
"must supply a same-length tuple to get_group "
"with multiple grouping keys"
)
raise ValueError(msg)

Expand Down
4 changes: 2 additions & 2 deletions pandas/core/groupby/grouper.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,8 @@ def is_in_obj(gpr) -> bool:

if is_categorical_dtype(gpr) and len(gpr) != obj.shape[axis]:
raise ValueError(
f"Length of grouper ({len(gpr)}) and axis ({obj.shape[axis]})"
" must be same length"
f"Length of grouper ({len(gpr)}) and axis ({obj.shape[axis]}) "
"must be same length"
)

# create the Grouping
Expand Down
5 changes: 2 additions & 3 deletions pandas/core/indexes/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2073,9 +2073,8 @@ def drop(self, codes, level=None, errors="raise"):
elif com.is_bool_indexer(loc):
if self.lexsort_depth == 0:
warnings.warn(
"dropping on a non-lexsorted multi-index"
" without a level parameter may impact "
"performance.",
"dropping on a non-lexsorted multi-index "
"without a level parameter may impact performance.",
PerformanceWarning,
stacklevel=3,
)
Expand Down
13 changes: 6 additions & 7 deletions pandas/core/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -1076,10 +1076,9 @@ def _upsample(self, method, limit=None, fill_value=None):
raise AssertionError("axis must be 0")
if self._from_selection:
raise ValueError(
"Upsampling from level= or on= selection"
" is not supported, use .set_index(...)"
" to explicitly set index to"
" datetime-like"
"Upsampling from level= or on= selection "
"is not supported, use .set_index(...) "
"to explicitly set index to datetime-like"
)

ax = self.ax
Expand Down Expand Up @@ -1135,9 +1134,9 @@ def _convert_obj(self, obj):
if self._from_selection:
# see GH 14008, GH 12871
msg = (
"Resampling from level= or on= selection"
" with a PeriodIndex is not currently supported,"
" use .set_index(...) to explicitly set index"
"Resampling from level= or on= selection "
"with a PeriodIndex is not currently supported, "
"use .set_index(...) to explicitly set index"
)
raise NotImplementedError(msg)

Expand Down
12 changes: 6 additions & 6 deletions pandas/core/reshape/concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,8 @@ def __init__(
for obj in objs:
if not isinstance(obj, (Series, DataFrame)):
msg = (
"cannot concatenate object of type '{typ}';"
" only Series and DataFrame objs are valid".format(typ=type(obj))
"cannot concatenate object of type '{typ}'; "
"only Series and DataFrame objs are valid".format(typ=type(obj))
)
raise TypeError(msg)

Expand Down Expand Up @@ -402,8 +402,8 @@ def __init__(
self._is_series = isinstance(sample, Series)
if not 0 <= axis <= sample.ndim:
raise AssertionError(
"axis must be between 0 and {ndim}, input was"
" {axis}".format(ndim=sample.ndim, axis=axis)
"axis must be between 0 and {ndim}, input was "
"{axis}".format(ndim=sample.ndim, axis=axis)
)

# if we have mixed ndims, then convert to highest ndim
Expand Down Expand Up @@ -648,8 +648,8 @@ def _make_concat_multiindex(indexes, keys, levels=None, names=None) -> MultiInde
# make sure that all of the passed indices have the same nlevels
if not len({idx.nlevels for idx in indexes}) == 1:
raise AssertionError(
"Cannot concat indices that do"
" not have the same number of levels"
"Cannot concat indices that do "
"not have the same number of levels"
)

# also copies
Expand Down
8 changes: 4 additions & 4 deletions pandas/core/reshape/melt.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def melt(
missing = Index(com.flatten(id_vars)).difference(cols)
if not missing.empty:
raise KeyError(
"The following 'id_vars' are not present"
" in the DataFrame: {missing}"
"The following 'id_vars' are not present "
"in the DataFrame: {missing}"
"".format(missing=list(missing))
)
else:
Expand All @@ -73,8 +73,8 @@ def melt(
missing = Index(com.flatten(value_vars)).difference(cols)
if not missing.empty:
raise KeyError(
"The following 'value_vars' are not present in"
" the DataFrame: {missing}"
"The following 'value_vars' are not present in "
"the DataFrame: {missing}"
"".format(missing=list(missing))
)
frame = frame.loc[:, id_vars + value_vars]
Expand Down
20 changes: 10 additions & 10 deletions pandas/core/reshape/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -1246,32 +1246,32 @@ def _validate(self, validate: str):
if validate in ["one_to_one", "1:1"]:
if not left_unique and not right_unique:
raise MergeError(
"Merge keys are not unique in either left"
" or right dataset; not a one-to-one merge"
"Merge keys are not unique in either left "
"or right dataset; not a one-to-one merge"
)
elif not left_unique:
raise MergeError(
"Merge keys are not unique in left dataset;"
" not a one-to-one merge"
"Merge keys are not unique in left dataset; "
"not a one-to-one merge"
)
elif not right_unique:
raise MergeError(
"Merge keys are not unique in right dataset;"
" not a one-to-one merge"
"Merge keys are not unique in right dataset; "
"not a one-to-one merge"
)

elif validate in ["one_to_many", "1:m"]:
if not left_unique:
raise MergeError(
"Merge keys are not unique in left dataset;"
" not a one-to-many merge"
"Merge keys are not unique in left dataset; "
"not a one-to-many merge"
)

elif validate in ["many_to_one", "m:1"]:
if not right_unique:
raise MergeError(
"Merge keys are not unique in right dataset;"
" not a many-to-one merge"
"Merge keys are not unique in right dataset; "
"not a many-to-one merge"
)

elif validate in ["many_to_many", "m:m"]:
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,8 @@ def str_contains(arr, pat, case=True, flags=0, na=np.nan, regex=True):

if regex.groups > 0:
warnings.warn(
"This pattern has match groups. To actually get the"
" groups, use str.extract.",
"This pattern has match groups. To actually get the "
"groups, use str.extract.",
UserWarning,
stacklevel=3,
)
Expand Down
4 changes: 2 additions & 2 deletions pandas/io/clipboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def read_clipboard(sep=r"\s+", **kwargs): # pragma: no cover
kwargs["engine"] = "python"
elif len(sep) > 1 and kwargs.get("engine") == "c":
warnings.warn(
"read_clipboard with regex separator does not work"
" properly with c engine"
"read_clipboard with regex separator does not work "
"properly with c engine"
)

return read_csv(StringIO(text), sep=sep, **kwargs)
Expand Down
4 changes: 2 additions & 2 deletions pandas/io/excel/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ def _validate_freeze_panes(freeze_panes):
return True

raise ValueError(
"freeze_panes must be of form (row, column)"
" where row and column are integers"
"freeze_panes must be of form (row, column) "
"where row and column are integers"
)

# freeze_panes wasn't specified, return False so it won't be applied
Expand Down
4 changes: 2 additions & 2 deletions pandas/io/formats/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,8 @@ def __init__(
else:
raise ValueError(
(
"Formatters length({flen}) should match"
" DataFrame number of columns({dlen})"
"Formatters length({flen}) should match "
"DataFrame number of columns({dlen})"
).format(flen=len(formatters), dlen=len(frame.columns))
)
self.na_rep = na_rep
Expand Down
6 changes: 3 additions & 3 deletions pandas/io/formats/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -1272,9 +1272,9 @@ def bar(
color = [color[0], color[0]]
elif len(color) > 2:
raise ValueError(
"`color` must be string or a list-like"
" of length 2: [`color_neg`, `color_pos`]"
" (eg: color=['#d65f5f', '#5fba7d'])"
"`color` must be string or a list-like "
"of length 2: [`color_neg`, `color_pos`] "
"(eg: color=['#d65f5f', '#5fba7d'])"
)

subset = _maybe_numeric_slice(self.data, subset)
Expand Down
16 changes: 8 additions & 8 deletions pandas/io/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,9 +612,9 @@ def parser_f(

if delim_whitespace and delimiter != default_sep:
raise ValueError(
"Specified a delimiter with both sep and"
" delim_whitespace=True; you can only"
" specify one."
"Specified a delimiter with both sep and "
"delim_whitespace=True; you can only "
"specify one."
)

if engine is not None:
Expand Down Expand Up @@ -956,8 +956,8 @@ def _clean_options(self, options, engine):
if sep is None and not delim_whitespace:
if engine == "c":
fallback_reason = (
"the 'c' engine does not support"
" sep=None with delim_whitespace=False"
"the 'c' engine does not support "
"sep=None with delim_whitespace=False"
)
engine = "python"
elif sep is not None and len(sep) > 1:
Expand Down Expand Up @@ -1120,9 +1120,9 @@ def _make_engine(self, engine="c"):
klass = FixedWidthFieldParser
else:
raise ValueError(
f"Unknown engine: {engine} (valid options are"
' "c", "python", or'
' "python-fwf")'
f"Unknown engine: {engine} (valid options are "
'"c", "python", or '
'"python-fwf")'
)
self._engine = klass(self.f, **self.options)

Expand Down
10 changes: 4 additions & 6 deletions pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -1215,9 +1215,8 @@ def append_to_multiple(
"""
if axes is not None:
raise TypeError(
"axes is currently not accepted as a parameter to"
" append_to_multiple; you can create the "
"tables independently instead"
"axes is currently not accepted as a parameter to append_to_multiple; "
"you can create the tables independently instead"
)

if not isinstance(d, dict):
Expand Down Expand Up @@ -3548,9 +3547,8 @@ def create_index(self, columns=None, optlevel=None, kind: Optional[str] = None):
if not v.is_indexed:
if v.type.startswith("complex"):
raise TypeError(
"Columns containing complex values can be stored "
"but cannot"
" be indexed when using table format. Either use "
"Columns containing complex values can be stored but "
"cannot be indexed when using table format. Either use "
"fixed format, set index=False, or do not include "
"the columns containing complex values to "
"data_columns when initializing the table."
Expand Down
7 changes: 3 additions & 4 deletions pandas/plotting/_matplotlib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,9 @@ def _validate_color_args(self):
for char in s:
if char in matplotlib.colors.BASE_COLORS:
raise ValueError(
"Cannot pass 'style' string with a color "
"symbol and 'color' keyword argument. Please"
" use one or the other or pass 'style' "
"without a color symbol"
"Cannot pass 'style' string with a color symbol and "
"'color' keyword argument. Please use one or the other or "
"pass 'style' without a color symbol"
)

def _iter_data(self, data=None, keep_index=False, fillna=None):
Expand Down
Loading