Skip to content

STY: Underscores for long numbers #30169

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 2 commits into from
Dec 10, 2019
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
12 changes: 6 additions & 6 deletions pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1076,9 +1076,9 @@ def tz_localize(self, tz, ambiguous="raise", nonexistent="raise"):
nonexistent, timedelta
):
raise ValueError(
"The nonexistent argument must be one of 'raise',"
" 'NaT', 'shift_forward', 'shift_backward' or"
" a timedelta object"
"The nonexistent argument must be one of 'raise', "
"'NaT', 'shift_forward', 'shift_backward' or "
"a timedelta object"
)

if self.tz is not None:
Expand Down Expand Up @@ -1151,7 +1151,7 @@ def normalize(self):
"""
if self.tz is None or timezones.is_utc(self.tz):
not_null = ~self.isna()
DAY_NS = ccalendar.DAY_SECONDS * 1000000000
DAY_NS = ccalendar.DAY_SECONDS * 1_000_000_000
new_values = self.asi8.copy()
adjustment = new_values[not_null] % DAY_NS
new_values[not_null] = new_values[not_null] - adjustment
Expand Down Expand Up @@ -1767,7 +1767,7 @@ def to_julian_date(self):
+ np.floor(year / 4)
- np.floor(year / 100)
+ np.floor(year / 400)
+ 1721118.5
+ 1_721_118.5
+ (
self.hour
+ self.minute / 60.0
Expand Down Expand Up @@ -2031,7 +2031,7 @@ def maybe_convert_dtype(data, copy):
# Note: without explicitly raising here, PeriodIndex
# test_setops.test_join_does_not_recur fails
raise TypeError(
"Passing PeriodDtype data is invalid. Use `data.to_timestamp()` instead"
"Passing PeriodDtype data is invalid. Use `data.to_timestamp()` instead"
)

elif is_categorical_dtype(data):
Expand Down
1 change: 0 additions & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,6 @@ def _repr_fits_horizontal_(self, ignore_width: bool = False) -> bool:
users expect. display.max_columns remains in effect.
GH3541, GH3573
"""

width, height = console.get_console_size()
max_columns = get_option("display.max_columns")
nb_columns = len(self.columns)
Expand Down
7 changes: 3 additions & 4 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -9165,7 +9165,6 @@ def truncate(
2016-01-10 23:59:58 1
2016-01-10 23:59:59 1
"""

if axis is None:
axis = self._stat_axis_number
axis = self._get_axis_number(axis)
Expand Down Expand Up @@ -9391,9 +9390,9 @@ def tz_localize(
nonexistent, timedelta
):
raise ValueError(
"The nonexistent argument must be one of 'raise',"
" 'NaT', 'shift_forward', 'shift_backward' or"
" a timedelta object"
"The nonexistent argument must be one of 'raise', "
"'NaT', 'shift_forward', 'shift_backward' or "
"a timedelta object"
)

axis = self._get_axis_number(axis)
Expand Down
12 changes: 5 additions & 7 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ def __init__(
if is_empty_data(data) and dtype is None:
# gh-17261
warnings.warn(
"The default dtype for empty Series will be 'object' instead"
" of 'float64' in a future version. Specify a dtype explicitly"
" to silence this warning.",
"The default dtype for empty Series will be 'object' instead "
"of 'float64' in a future version. Specify a dtype explicitly "
"to silence this warning.",
DeprecationWarning,
stacklevel=2,
)
Expand Down Expand Up @@ -257,14 +257,13 @@ def __init__(
raise AssertionError(
"Cannot pass both SingleBlockManager "
"`data` argument and a different "
"`index` argument. `copy` must "
"be False."
"`index` argument. `copy` must be False."
)

elif is_extension_array_dtype(data):
pass
elif isinstance(data, (set, frozenset)):
raise TypeError(f"{repr(type(data).__name__)} type is unordered")
raise TypeError(f"'{type(data).__name__}' type is unordered")
elif isinstance(data, ABCSparseArray):
# handle sparse passed here (and force conversion)
data = data.to_dense()
Expand Down Expand Up @@ -3721,7 +3720,6 @@ def _reduce(
If we have an ndarray as a value, then simply perform the operation,
otherwise delegate to the object.
"""

delegate = self._values

if axis is not None:
Expand Down
11 changes: 4 additions & 7 deletions pandas/core/tools/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -838,19 +838,16 @@ def coerce(values):
)
try:
values = to_datetime(values, format="%Y%m%d", errors=errors, utc=tz)
except (TypeError, ValueError) as e:
raise ValueError("cannot assemble the datetimes: {error}".format(error=e))
except (TypeError, ValueError) as err:
raise ValueError(f"cannot assemble the datetimes: {err}")

for u in ["h", "m", "s", "ms", "us", "ns"]:
value = unit_rev.get(u)
if value is not None and value in arg:
try:
values += to_timedelta(coerce(arg[value]), unit=u, errors=errors)
except (TypeError, ValueError) as e:
raise ValueError(
"cannot assemble the datetimes [{value}]: "
"{error}".format(value=value, error=e)
)
except (TypeError, ValueError) as err:
raise ValueError(f"cannot assemble the datetimes [{value}]: {err}")
return values


Expand Down
3 changes: 1 addition & 2 deletions pandas/core/window/ewm.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,7 @@ def _apply(self, func, **kwargs):
cfunc = getattr(window_aggregations, func, None)
if cfunc is None:
raise ValueError(
"we do not support this function "
f"in window_aggregations.{func}"
f"we do not support this function in window_aggregations.{func}"
)

def func(arg):
Expand Down