Skip to content

Commit eddfb8f

Browse files
author
MomIsBestFriend
committed
Decimal
1 parent e0e778d commit eddfb8f

File tree

5 files changed

+50
-65
lines changed

5 files changed

+50
-65
lines changed

pandas/core/arrays/categorical.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ class Categorical(ExtensionArray, PandasObject):
299299

300300
# For comparisons, so that numpy uses our implementation if the compare
301301
# ops, which raise
302-
__array_priority__ = 1_000
302+
__array_priority__ = 1000
303303
_dtype = CategoricalDtype(ordered=False)
304304
# tolist is not actually deprecated, just suppressed in the __dir__
305305
_deprecations = PandasObject._deprecations | frozenset(["tolist", "itemsize"])

pandas/core/arrays/timedeltas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class TimedeltaArray(dtl.DatetimeLikeArrayMixin, dtl.TimelikeOps):
157157

158158
_typ = "timedeltaarray"
159159
_scalar_type = Timedelta
160-
__array_priority__ = 1_000
160+
__array_priority__ = 1000
161161
# define my properties & methods for delegation
162162
_other_ops: List[str] = []
163163
_bool_ops: List[str] = []

pandas/core/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ class IndexOpsMixin:
618618
"""
619619

620620
# ndarray compatibility
621-
__array_priority__ = 1_000
621+
__array_priority__ = 1000
622622
_deprecations: FrozenSet[str] = frozenset(
623623
["tolist", "item"] # tolist is not deprecated, just suppressed in the __dir__
624624
)

pandas/tests/io/formats/test_format.py

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,11 @@ def test_repr_chop_threshold_column_below(self):
286286
)
287287

288288
def test_repr_obeys_max_seq_limit(self):
289-
with option_context("display.max_seq_items", 2_000):
290-
assert len(printing.pprint_thing(list(range(1_000)))) > 1_000
289+
with option_context("display.max_seq_items", 2000):
290+
assert len(printing.pprint_thing(list(range(1000)))) > 1000
291291

292292
with option_context("display.max_seq_items", 5):
293-
assert len(printing.pprint_thing(list(range(1_000)))) < 100
293+
assert len(printing.pprint_thing(list(range(1000)))) < 100
294294

295295
def test_repr_set(self):
296296
assert printing.pprint_thing({1}) == "{1}"
@@ -354,10 +354,10 @@ def test_expand_frame_repr(self):
354354
def test_repr_non_interactive(self):
355355
# in non interactive mode, there can be no dependency on the
356356
# result of terminal auto size detection
357-
df = DataFrame("hello", index=range(1_000), columns=range(5))
357+
df = DataFrame("hello", index=range(1000), columns=range(5))
358358

359359
with option_context(
360-
"mode.sim_interactive", False, "display.width", 0, "display.max_rows", 5_000
360+
"mode.sim_interactive", False, "display.width", 0, "display.max_rows", 5000
361361
):
362362
assert not has_truncated_repr(df)
363363
assert not has_expanded_repr(df)
@@ -1339,7 +1339,7 @@ def test_wide_repr_wide_long_columns(self):
13391339
assert "ddddd" in result
13401340

13411341
def test_long_series(self):
1342-
n = 1_000
1342+
n = 1000
13431343
s = Series(
13441344
np.random.randint(-50, 50, n),
13451345
index=["s{x:04d}".format(x=x) for x in range(n)],
@@ -1545,7 +1545,7 @@ def test_to_string_float_formatting(self):
15451545
)
15461546

15471547
df = DataFrame(
1548-
{"x": [0, 0.25, 3_456.000, 12e45, 1.64e6, 1.7e8, 1.253_456, np.pi, -1e6]}
1548+
{"x": [0, 0.25, 3456.000, 12e45, 1.64e6, 1.7e8, 1.253_456, np.pi, -1e6]}
15491549
)
15501550

15511551
df_s = df.to_string()
@@ -1566,7 +1566,7 @@ def test_to_string_float_formatting(self):
15661566
)
15671567
assert df_s == expected
15681568

1569-
df = DataFrame({"x": [3_234, 0.253]})
1569+
df = DataFrame({"x": [3234, 0.253]})
15701570
df_s = df.to_string()
15711571

15721572
expected = " x\n0 3234.000\n1 0.253"
@@ -1636,9 +1636,9 @@ def test_to_string_complex_float_formatting(self):
16361636
df = DataFrame(
16371637
{
16381638
"x": [
1639-
(0.4_467_846_931_321_966 + 0.0_715_185_102_060_818j),
1640-
(0.2_739_442_392_974_528 + 0.23_515_228_785_438_969j),
1641-
(0.26_974_928_742_135_185 + 0.3_250_604_054_898_979j),
1639+
(0.4467846931321966 + 0.0715185102060818j),
1640+
(0.2739442392974528 + 0.23515228785438969j),
1641+
(0.26974928742135185 + 0.3250604054898979j),
16421642
(-1j),
16431643
]
16441644
}
@@ -1690,7 +1690,7 @@ def test_to_string_index_formatter(self):
16901690

16911691
def test_to_string_left_justify_cols(self):
16921692
tm.reset_display_options()
1693-
df = DataFrame({"x": [3_234, 0.253]})
1693+
df = DataFrame({"x": [3234, 0.253]})
16941694
df_s = df.to_string(justify="left")
16951695
expected = " x \n0 3234.000\n1 0.253"
16961696
assert df_s == expected
@@ -1699,7 +1699,7 @@ def test_to_string_format_na(self):
16991699
tm.reset_display_options()
17001700
df = DataFrame(
17011701
{
1702-
"A": [np.nan, -1, -2.1_234, 3, 4],
1702+
"A": [np.nan, -1, -2.1234, 3, 4],
17031703
"B": [np.nan, "foo", "foooo", "fooooo", "bar"],
17041704
}
17051705
)
@@ -1738,7 +1738,7 @@ def test_to_string_format_inf(self):
17381738
tm.reset_display_options()
17391739
df = DataFrame(
17401740
{
1741-
"A": [-np.inf, np.inf, -1, -2.1_234, 3, 4],
1741+
"A": [-np.inf, np.inf, -1, -2.1234, 3, 4],
17421742
"B": [-np.inf, np.inf, "foo", "foooo", "fooooo", "bar"],
17431743
}
17441744
)
@@ -2076,11 +2076,11 @@ def __getitem__(self, key):
20762076

20772077
def test_float_trim_zeros(self):
20782078
vals = [
2079-
2.08_430_917_305e10,
2080-
3.52_205_017_305e10,
2081-
2.30_674_817_305e10,
2082-
2.03_954_217_305e10,
2083-
5.59_897_817_305e10,
2079+
2.08430917305e10,
2080+
3.52205017305e10,
2081+
2.30674817305e10,
2082+
2.03954217305e10,
2083+
5.59897817305e10,
20842084
]
20852085
skip = True
20862086
for line in repr(DataFrame({"A": vals})).split("\n")[:-2]:
@@ -2140,7 +2140,7 @@ def test_repr_unicode(self):
21402140
s = Series(["\u03c3"] * 10)
21412141
repr(s)
21422142

2143-
a = Series(["\u05d0"] * 1_000)
2143+
a = Series(["\u05d0"] * 1000)
21442144
a.name = "title1"
21452145
repr(a)
21462146

@@ -2202,7 +2202,7 @@ def test_to_string_mixed(self):
22022202
assert result == expected
22032203

22042204
def test_to_string_float_na_spacing(self):
2205-
s = Series([0.0, 1.5_678, 2.0, -3.0, 4.0])
2205+
s = Series([0.0, 1.5678, 2.0, -3.0, 4.0])
22062206
s[::2] = np.nan
22072207

22082208
result = s.to_string()
@@ -2261,7 +2261,7 @@ def test_east_asian_unicode_series(self):
22612261
idx = pd.MultiIndex.from_tuples(
22622262
[("あ", "いい"), ("う", "え"), ("おおお", "かかかか"), ("き", "くく")]
22632263
)
2264-
s = Series([1, 22, 3_333, 44_444], index=idx)
2264+
s = Series([1, 22, 3333, 44_444], index=idx)
22652265
expected = (
22662266
"あ いい 1\n"
22672267
"う え 22\n"
@@ -2271,15 +2271,15 @@ def test_east_asian_unicode_series(self):
22712271
assert repr(s) == expected
22722272

22732273
# object dtype, shorter than unicode repr
2274-
s = Series([1, 22, 3_333, 44_444], index=[1, "AB", np.nan, "あああ"])
2274+
s = Series([1, 22, 3333, 44_444], index=[1, "AB", np.nan, "あああ"])
22752275
expected = (
22762276
"1 1\nAB 22\nNaN 3333\nあああ 44444\ndtype: int64"
22772277
)
22782278
assert repr(s) == expected
22792279

22802280
# object dtype, longer than unicode repr
22812281
s = Series(
2282-
[1, 22, 3_333, 44_444], index=[1, "AB", pd.Timestamp("2011-01-01"), "あああ"]
2282+
[1, 22, 3333, 44_444], index=[1, "AB", pd.Timestamp("2011-01-01"), "あああ"]
22832283
)
22842284
expected = (
22852285
"1 1\n"
@@ -2356,7 +2356,7 @@ def test_east_asian_unicode_series(self):
23562356
idx = pd.MultiIndex.from_tuples(
23572357
[("あ", "いい"), ("う", "え"), ("おおお", "かかかか"), ("き", "くく")]
23582358
)
2359-
s = Series([1, 22, 3_333, 44_444], index=idx)
2359+
s = Series([1, 22, 3333, 44_444], index=idx)
23602360
expected = (
23612361
"あ いい 1\n"
23622362
"う え 22\n"
@@ -2367,7 +2367,7 @@ def test_east_asian_unicode_series(self):
23672367
assert repr(s) == expected
23682368

23692369
# object dtype, shorter than unicode repr
2370-
s = Series([1, 22, 3_333, 44_444], index=[1, "AB", np.nan, "あああ"])
2370+
s = Series([1, 22, 3333, 44_444], index=[1, "AB", np.nan, "あああ"])
23712371
expected = (
23722372
"1 1\nAB 22\nNaN 3333\n"
23732373
"あああ 44444\ndtype: int64"
@@ -2376,7 +2376,7 @@ def test_east_asian_unicode_series(self):
23762376

23772377
# object dtype, longer than unicode repr
23782378
s = Series(
2379-
[1, 22, 3_333, 44_444],
2379+
[1, 22, 3333, 44_444],
23802380
index=[1, "AB", pd.Timestamp("2011-01-01"), "あああ"],
23812381
)
23822382
expected = (
@@ -2420,11 +2420,11 @@ def test_east_asian_unicode_series(self):
24202420

24212421
def test_float_trim_zeros(self):
24222422
vals = [
2423-
2.08_430_917_305e10,
2424-
3.52_205_017_305e10,
2425-
2.30_674_817_305e10,
2426-
2.03_954_217_305e10,
2427-
5.59_897_817_305e10,
2423+
2.08430917305e10,
2424+
3.52205017305e10,
2425+
2.30674817305e10,
2426+
2.03954217305e10,
2427+
5.59897817305e10,
24282428
]
24292429
for line in repr(Series(vals)).split("\n"):
24302430
if line.startswith("dtype:"):
@@ -2624,7 +2624,7 @@ def test_max_multi_index_display(self):
26242624

26252625
# Make sure #8532 is fixed
26262626
def test_consistent_format(self):
2627-
s = pd.Series([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9_999, 1, 1] * 10)
2627+
s = pd.Series([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9999, 1, 1] * 10)
26282628
with option_context("display.max_rows", 10, "display.show_dimensions", False):
26292629
res = repr(s)
26302630
exp = (
@@ -2824,19 +2824,19 @@ def test_output_significant_digits(self):
28242824
"col1": [
28252825
9.999e-8,
28262826
1e-7,
2827-
1.0_001e-7,
2827+
1.0001e-7,
28282828
2e-7,
28292829
4.999e-7,
28302830
5e-7,
2831-
5.0_001e-7,
2831+
5.0001e-7,
28322832
6e-7,
28332833
9.999e-7,
28342834
1e-6,
2835-
1.0_001e-6,
2835+
1.0001e-6,
28362836
2e-6,
28372837
4.999e-6,
28382838
5e-6,
2839-
5.0_001e-6,
2839+
5.0001e-6,
28402840
6e-6,
28412841
]
28422842
}
@@ -2891,7 +2891,7 @@ def test_too_long(self):
28912891
with pd.option_context("display.precision", 4):
28922892
# need both a number > 1e6 and something that normally formats to
28932893
# having length > display.precision + 6
2894-
df = pd.DataFrame(dict(x=[12_345.6_789]))
2894+
df = pd.DataFrame(dict(x=[12_345.6789]))
28952895
assert str(df) == " x\n0 12345.6789"
28962896
df = pd.DataFrame(dict(x=[2e6]))
28972897
assert str(df) == " x\n0 2000000.0"

pandas/tests/io/parser/test_usecols.py

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,9 @@ def test_usecols_with_whitespace(all_parsers):
197197
"usecols,expected",
198198
[
199199
# Column selection by index.
200-
([0, 1], DataFrame(data=[[1_000, 2_000], [4_000, 5_000]], columns=["2", "0"])),
200+
([0, 1], DataFrame(data=[[1000, 2000], [4000, 5000]], columns=["2", "0"])),
201201
# Column selection by name.
202-
(
203-
["0", "1"],
204-
DataFrame(data=[[2_000, 3_000], [5_000, 6_000]], columns=["0", "1"]),
205-
),
202+
(["0", "1"], DataFrame(data=[[2000, 3000], [5000, 6000]], columns=["0", "1"]),),
206203
],
207204
)
208205
def test_usecols_with_integer_like_header(all_parsers, usecols, expected):
@@ -252,7 +249,7 @@ def test_usecols_with_parse_dates2(all_parsers):
252249
],
253250
name="date",
254251
)
255-
cols = {"values": [1_032.43, 1_042.54, 1_051.65]}
252+
cols = {"values": [1032.43, 1042.54, 1051.65]}
256253
expected = DataFrame(cols, index=index)
257254

258255
result = parser.read_csv(
@@ -352,11 +349,7 @@ def test_usecols_with_unicode_strings(all_parsers):
352349
parser = all_parsers
353350

354351
exp_data = {
355-
"AAA": {
356-
0: 0.056_674_972_999_999_997,
357-
1: 2.6_132_309_819_999_997,
358-
2: 3.5_689_350_380_000_002,
359-
},
352+
"AAA": {0: 0.056674972999999997, 1: 2.6132309819999997, 2: 3.5689350380000002,},
360353
"BBB": {0: 8, 1: 2, 2: 7},
361354
}
362355
expected = DataFrame(exp_data)
@@ -374,11 +367,7 @@ def test_usecols_with_single_byte_unicode_strings(all_parsers):
374367
parser = all_parsers
375368

376369
exp_data = {
377-
"A": {
378-
0: 0.056_674_972_999_999_997,
379-
1: 2.6_132_309_819_999_997,
380-
2: 3.5_689_350_380_000_002,
381-
},
370+
"A": {0: 0.056674972999999997, 1: 2.6132309819999997, 2: 3.5689350380000002,},
382371
"B": {0: 8, 1: 2, 2: 7},
383372
}
384373
expected = DataFrame(exp_data)
@@ -408,11 +397,7 @@ def test_usecols_with_multi_byte_characters(all_parsers, usecols):
408397
parser = all_parsers
409398

410399
exp_data = {
411-
"あああ": {
412-
0: 0.056_674_972_999_999_997,
413-
1: 2.6_132_309_819_999_997,
414-
2: 3.5_689_350_380_000_002,
415-
},
400+
"あああ": {0: 0.056674972999999997, 1: 2.6132309819999997, 2: 3.5689350380000002,},
416401
"いい": {0: 8, 1: 2, 2: 7},
417402
}
418403
expected = DataFrame(exp_data)
@@ -449,9 +434,9 @@ def test_np_array_usecols(all_parsers):
449434
DataFrame(
450435
{
451436
"AaA": {
452-
0: 0.056_674_972_999_999_997,
453-
1: 2.6_132_309_819_999_997,
454-
2: 3.5_689_350_380_000_002,
437+
0: 0.056674972999999997,
438+
1: 2.6132309819999997,
439+
2: 3.5689350380000002,
455440
},
456441
"bBb": {0: 8, 1: 2, 2: 7},
457442
"ddd": {0: "a", 1: "b", 2: "a"},

0 commit comments

Comments
 (0)