Skip to content

Commit 71cdd50

Browse files
ShaharNavehjreback
authored andcommitted
STY: Underscores for long numbers (#30169)
1 parent 6daa4a0 commit 71cdd50

File tree

6 files changed

+19
-27
lines changed

6 files changed

+19
-27
lines changed

pandas/core/arrays/datetimes.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -1076,9 +1076,9 @@ def tz_localize(self, tz, ambiguous="raise", nonexistent="raise"):
10761076
nonexistent, timedelta
10771077
):
10781078
raise ValueError(
1079-
"The nonexistent argument must be one of 'raise',"
1080-
" 'NaT', 'shift_forward', 'shift_backward' or"
1081-
" a timedelta object"
1079+
"The nonexistent argument must be one of 'raise', "
1080+
"'NaT', 'shift_forward', 'shift_backward' or "
1081+
"a timedelta object"
10821082
)
10831083

10841084
if self.tz is not None:
@@ -1151,7 +1151,7 @@ def normalize(self):
11511151
"""
11521152
if self.tz is None or timezones.is_utc(self.tz):
11531153
not_null = ~self.isna()
1154-
DAY_NS = ccalendar.DAY_SECONDS * 1000000000
1154+
DAY_NS = ccalendar.DAY_SECONDS * 1_000_000_000
11551155
new_values = self.asi8.copy()
11561156
adjustment = new_values[not_null] % DAY_NS
11571157
new_values[not_null] = new_values[not_null] - adjustment
@@ -1767,7 +1767,7 @@ def to_julian_date(self):
17671767
+ np.floor(year / 4)
17681768
- np.floor(year / 100)
17691769
+ np.floor(year / 400)
1770-
+ 1721118.5
1770+
+ 1_721_118.5
17711771
+ (
17721772
self.hour
17731773
+ self.minute / 60.0
@@ -2031,7 +2031,7 @@ def maybe_convert_dtype(data, copy):
20312031
# Note: without explicitly raising here, PeriodIndex
20322032
# test_setops.test_join_does_not_recur fails
20332033
raise TypeError(
2034-
"Passing PeriodDtype data is invalid. Use `data.to_timestamp()` instead"
2034+
"Passing PeriodDtype data is invalid. Use `data.to_timestamp()` instead"
20352035
)
20362036

20372037
elif is_categorical_dtype(data):

pandas/core/frame.py

-1
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,6 @@ def _repr_fits_horizontal_(self, ignore_width: bool = False) -> bool:
593593
users expect. display.max_columns remains in effect.
594594
GH3541, GH3573
595595
"""
596-
597596
width, height = console.get_console_size()
598597
max_columns = get_option("display.max_columns")
599598
nb_columns = len(self.columns)

pandas/core/generic.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -9165,7 +9165,6 @@ def truncate(
91659165
2016-01-10 23:59:58 1
91669166
2016-01-10 23:59:59 1
91679167
"""
9168-
91699168
if axis is None:
91709169
axis = self._stat_axis_number
91719170
axis = self._get_axis_number(axis)
@@ -9391,9 +9390,9 @@ def tz_localize(
93919390
nonexistent, timedelta
93929391
):
93939392
raise ValueError(
9394-
"The nonexistent argument must be one of 'raise',"
9395-
" 'NaT', 'shift_forward', 'shift_backward' or"
9396-
" a timedelta object"
9393+
"The nonexistent argument must be one of 'raise', "
9394+
"'NaT', 'shift_forward', 'shift_backward' or "
9395+
"a timedelta object"
93979396
)
93989397

93999398
axis = self._get_axis_number(axis)

pandas/core/series.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@ def __init__(
197197
if is_empty_data(data) and dtype is None:
198198
# gh-17261
199199
warnings.warn(
200-
"The default dtype for empty Series will be 'object' instead"
201-
" of 'float64' in a future version. Specify a dtype explicitly"
202-
" to silence this warning.",
200+
"The default dtype for empty Series will be 'object' instead "
201+
"of 'float64' in a future version. Specify a dtype explicitly "
202+
"to silence this warning.",
203203
DeprecationWarning,
204204
stacklevel=2,
205205
)
@@ -257,14 +257,13 @@ def __init__(
257257
raise AssertionError(
258258
"Cannot pass both SingleBlockManager "
259259
"`data` argument and a different "
260-
"`index` argument. `copy` must "
261-
"be False."
260+
"`index` argument. `copy` must be False."
262261
)
263262

264263
elif is_extension_array_dtype(data):
265264
pass
266265
elif isinstance(data, (set, frozenset)):
267-
raise TypeError(f"{repr(type(data).__name__)} type is unordered")
266+
raise TypeError(f"'{type(data).__name__}' type is unordered")
268267
elif isinstance(data, ABCSparseArray):
269268
# handle sparse passed here (and force conversion)
270269
data = data.to_dense()
@@ -3721,7 +3720,6 @@ def _reduce(
37213720
If we have an ndarray as a value, then simply perform the operation,
37223721
otherwise delegate to the object.
37233722
"""
3724-
37253723
delegate = self._values
37263724

37273725
if axis is not None:

pandas/core/tools/datetimes.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -838,19 +838,16 @@ def coerce(values):
838838
)
839839
try:
840840
values = to_datetime(values, format="%Y%m%d", errors=errors, utc=tz)
841-
except (TypeError, ValueError) as e:
842-
raise ValueError("cannot assemble the datetimes: {error}".format(error=e))
841+
except (TypeError, ValueError) as err:
842+
raise ValueError(f"cannot assemble the datetimes: {err}")
843843

844844
for u in ["h", "m", "s", "ms", "us", "ns"]:
845845
value = unit_rev.get(u)
846846
if value is not None and value in arg:
847847
try:
848848
values += to_timedelta(coerce(arg[value]), unit=u, errors=errors)
849-
except (TypeError, ValueError) as e:
850-
raise ValueError(
851-
"cannot assemble the datetimes [{value}]: "
852-
"{error}".format(value=value, error=e)
853-
)
849+
except (TypeError, ValueError) as err:
850+
raise ValueError(f"cannot assemble the datetimes [{value}]: {err}")
854851
return values
855852

856853

pandas/core/window/ewm.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,7 @@ def _apply(self, func, **kwargs):
231231
cfunc = getattr(window_aggregations, func, None)
232232
if cfunc is None:
233233
raise ValueError(
234-
"we do not support this function "
235-
f"in window_aggregations.{func}"
234+
f"we do not support this function in window_aggregations.{func}"
236235
)
237236

238237
def func(arg):

0 commit comments

Comments
 (0)