@@ -249,7 +249,7 @@ def test_repr_deprecation_negative_int(self):
249
249
250
250
def test_repr_chop_threshold (self ):
251
251
df = DataFrame ([[0.1 , 0.5 ], [0.5 , - 0.1 ]])
252
- pd . reset_option ("display.chop_threshold" ) # default None
252
+ reset_option ("display.chop_threshold" ) # default None
253
253
assert repr (df ) == " 0 1\n 0 0.1 0.5\n 1 0.5 -0.1"
254
254
255
255
with option_context ("display.chop_threshold" , 0.2 ):
@@ -382,7 +382,7 @@ def test_repr_truncates_terminal_size(self, monkeypatch):
382
382
)
383
383
384
384
index = range (5 )
385
- columns = pd . MultiIndex .from_tuples (
385
+ columns = MultiIndex .from_tuples (
386
386
[
387
387
("This is a long title with > 37 chars." , "cat" ),
388
388
("This is a loooooonger title with > 43 chars." , "dog" ),
@@ -689,7 +689,7 @@ def test_east_asian_unicode_false(self):
689
689
assert repr (df ) == expected
690
690
691
691
# MultiIndex
692
- idx = pd . MultiIndex .from_tuples (
692
+ idx = MultiIndex .from_tuples (
693
693
[("あ" , "いい" ), ("う" , "え" ), ("おおお" , "かかかか" ), ("き" , "くく" )]
694
694
)
695
695
df = DataFrame (
@@ -833,7 +833,7 @@ def test_east_asian_unicode_true(self):
833
833
assert repr (df ) == expected
834
834
835
835
# MultiIndex
836
- idx = pd . MultiIndex .from_tuples (
836
+ idx = MultiIndex .from_tuples (
837
837
[("あ" , "いい" ), ("う" , "え" ), ("おおお" , "かかかか" ), ("き" , "くく" )]
838
838
)
839
839
df = DataFrame (
@@ -1002,14 +1002,14 @@ def test_truncate_with_different_dtypes(self):
1002
1002
+ [datetime .datetime (2012 , 1 , 3 )] * 10
1003
1003
)
1004
1004
1005
- with pd . option_context ("display.max_rows" , 8 ):
1005
+ with option_context ("display.max_rows" , 8 ):
1006
1006
result = str (s )
1007
1007
assert "object" in result
1008
1008
1009
1009
# 12045
1010
1010
df = DataFrame ({"text" : ["some words" ] + [None ] * 9 })
1011
1011
1012
- with pd . option_context ("display.max_rows" , 8 , "display.max_columns" , 3 ):
1012
+ with option_context ("display.max_rows" , 8 , "display.max_columns" , 3 ):
1013
1013
result = str (df )
1014
1014
assert "None" in result
1015
1015
assert "NaN" not in result
@@ -1026,9 +1026,7 @@ def test_truncate_with_different_dtypes_multiindex(self):
1026
1026
def test_datetimelike_frame (self ):
1027
1027
1028
1028
# GH 12211
1029
- df = DataFrame (
1030
- {"date" : [Timestamp ("20130101" ).tz_localize ("UTC" )] + [pd .NaT ] * 5 }
1031
- )
1029
+ df = DataFrame ({"date" : [Timestamp ("20130101" ).tz_localize ("UTC" )] + [NaT ] * 5 })
1032
1030
1033
1031
with option_context ("display.max_rows" , 5 ):
1034
1032
result = str (df )
@@ -1037,7 +1035,7 @@ def test_datetimelike_frame(self):
1037
1035
assert "..." in result
1038
1036
assert "[6 rows x 1 columns]" in result
1039
1037
1040
- dts = [Timestamp ("2011-01-01" , tz = "US/Eastern" )] * 5 + [pd . NaT ] * 5
1038
+ dts = [Timestamp ("2011-01-01" , tz = "US/Eastern" )] * 5 + [NaT ] * 5
1041
1039
df = DataFrame ({"dt" : dts , "x" : [1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ]})
1042
1040
with option_context ("display.max_rows" , 5 ):
1043
1041
expected = (
@@ -1051,7 +1049,7 @@ def test_datetimelike_frame(self):
1051
1049
)
1052
1050
assert repr (df ) == expected
1053
1051
1054
- dts = [pd . NaT ] * 5 + [Timestamp ("2011-01-01" , tz = "US/Eastern" )] * 5
1052
+ dts = [NaT ] * 5 + [Timestamp ("2011-01-01" , tz = "US/Eastern" )] * 5
1055
1053
df = DataFrame ({"dt" : dts , "x" : [1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ]})
1056
1054
with option_context ("display.max_rows" , 5 ):
1057
1055
expected = (
@@ -1117,7 +1115,7 @@ def test_unicode_problem_decoding_as_ascii(self):
1117
1115
1118
1116
def test_string_repr_encoding (self , datapath ):
1119
1117
filepath = datapath ("io" , "parser" , "data" , "unicode_series.csv" )
1120
- df = pd . read_csv (filepath , header = None , encoding = "latin1" )
1118
+ df = read_csv (filepath , header = None , encoding = "latin1" )
1121
1119
repr (df )
1122
1120
repr (df [1 ])
1123
1121
@@ -1548,7 +1546,7 @@ def test_to_string_float_index(self):
1548
1546
1549
1547
def test_to_string_complex_float_formatting (self ):
1550
1548
# GH #25514, 25745
1551
- with pd . option_context ("display.precision" , 5 ):
1549
+ with option_context ("display.precision" , 5 ):
1552
1550
df = DataFrame (
1553
1551
{
1554
1552
"x" : [
@@ -1785,7 +1783,7 @@ def test_repr_html_mathjax(self):
1785
1783
df = DataFrame ([[1 , 2 ], [3 , 4 ]])
1786
1784
assert "tex2jax_ignore" not in df ._repr_html_ ()
1787
1785
1788
- with pd . option_context ("display.html.use_mathjax" , False ):
1786
+ with option_context ("display.html.use_mathjax" , False ):
1789
1787
assert "tex2jax_ignore" in df ._repr_html_ ()
1790
1788
1791
1789
def test_repr_html_wide (self ):
@@ -2229,7 +2227,7 @@ def test_east_asian_unicode_series(self):
2229
2227
assert repr (s ) == expected
2230
2228
2231
2229
# MultiIndex
2232
- idx = pd . MultiIndex .from_tuples (
2230
+ idx = MultiIndex .from_tuples (
2233
2231
[("あ" , "いい" ), ("う" , "え" ), ("おおお" , "かかかか" ), ("き" , "くく" )]
2234
2232
)
2235
2233
s = Series ([1 , 22 , 3333 , 44444 ], index = idx )
@@ -2324,7 +2322,7 @@ def test_east_asian_unicode_series(self):
2324
2322
assert repr (s ) == expected
2325
2323
2326
2324
# MultiIndex
2327
- idx = pd . MultiIndex .from_tuples (
2325
+ idx = MultiIndex .from_tuples (
2328
2326
[("あ" , "いい" ), ("う" , "え" ), ("おおお" , "かかかか" ), ("き" , "くく" )]
2329
2327
)
2330
2328
s = Series ([1 , 22 , 3333 , 44444 ], index = idx )
@@ -2853,7 +2851,7 @@ def test_output_display_precision_trailing_zeroes(self):
2853
2851
# Issue #20359: trimming zeros while there is no decimal point
2854
2852
2855
2853
# Happens when display precision is set to zero
2856
- with pd . option_context ("display.precision" , 0 ):
2854
+ with option_context ("display.precision" , 0 ):
2857
2855
s = Series ([840.0 , 4200.0 ])
2858
2856
expected_output = "0 840\n 1 4200\n dtype: float64"
2859
2857
assert str (s ) == expected_output
@@ -2862,7 +2860,7 @@ def test_output_significant_digits(self):
2862
2860
# Issue #9764
2863
2861
2864
2862
# In case default display precision changes:
2865
- with pd . option_context ("display.precision" , 6 ):
2863
+ with option_context ("display.precision" , 6 ):
2866
2864
# DataFrame example from issue #9764
2867
2865
d = DataFrame (
2868
2866
{
@@ -2933,7 +2931,7 @@ def test_output_significant_digits(self):
2933
2931
2934
2932
def test_too_long (self ):
2935
2933
# GH 10451
2936
- with pd . option_context ("display.precision" , 4 ):
2934
+ with option_context ("display.precision" , 4 ):
2937
2935
# need both a number > 1e6 and something that normally formats to
2938
2936
# having length > display.precision + 6
2939
2937
df = DataFrame ({"x" : [12345.6789 ]})
@@ -3011,7 +3009,7 @@ def test_all(self):
3011
3009
3012
3010
class TestTimedelta64Formatter :
3013
3011
def test_days (self ):
3014
- x = pd .to_timedelta (list (range (5 )) + [pd . NaT ], unit = "D" )
3012
+ x = pd .to_timedelta (list (range (5 )) + [NaT ], unit = "D" )
3015
3013
result = fmt .Timedelta64Formatter (x , box = True ).get_result ()
3016
3014
assert result [0 ].strip () == "'0 days'"
3017
3015
assert result [1 ].strip () == "'1 days'"
@@ -3027,25 +3025,25 @@ def test_days(self):
3027
3025
assert result [0 ].strip () == "1 days"
3028
3026
3029
3027
def test_days_neg (self ):
3030
- x = pd .to_timedelta (list (range (5 )) + [pd . NaT ], unit = "D" )
3028
+ x = pd .to_timedelta (list (range (5 )) + [NaT ], unit = "D" )
3031
3029
result = fmt .Timedelta64Formatter (- x , box = True ).get_result ()
3032
3030
assert result [0 ].strip () == "'0 days'"
3033
3031
assert result [1 ].strip () == "'-1 days'"
3034
3032
3035
3033
def test_subdays (self ):
3036
- y = pd .to_timedelta (list (range (5 )) + [pd . NaT ], unit = "s" )
3034
+ y = pd .to_timedelta (list (range (5 )) + [NaT ], unit = "s" )
3037
3035
result = fmt .Timedelta64Formatter (y , box = True ).get_result ()
3038
3036
assert result [0 ].strip () == "'0 days 00:00:00'"
3039
3037
assert result [1 ].strip () == "'0 days 00:00:01'"
3040
3038
3041
3039
def test_subdays_neg (self ):
3042
- y = pd .to_timedelta (list (range (5 )) + [pd . NaT ], unit = "s" )
3040
+ y = pd .to_timedelta (list (range (5 )) + [NaT ], unit = "s" )
3043
3041
result = fmt .Timedelta64Formatter (- y , box = True ).get_result ()
3044
3042
assert result [0 ].strip () == "'0 days 00:00:00'"
3045
3043
assert result [1 ].strip () == "'-1 days +23:59:59'"
3046
3044
3047
3045
def test_zero (self ):
3048
- x = pd .to_timedelta (list (range (1 )) + [pd . NaT ], unit = "D" )
3046
+ x = pd .to_timedelta (list (range (1 )) + [NaT ], unit = "D" )
3049
3047
result = fmt .Timedelta64Formatter (x , box = True ).get_result ()
3050
3048
assert result [0 ].strip () == "'0 days'"
3051
3049
@@ -3056,13 +3054,13 @@ def test_zero(self):
3056
3054
3057
3055
class TestDatetime64Formatter :
3058
3056
def test_mixed (self ):
3059
- x = Series ([datetime (2013 , 1 , 1 ), datetime (2013 , 1 , 1 , 12 ), pd . NaT ])
3057
+ x = Series ([datetime (2013 , 1 , 1 ), datetime (2013 , 1 , 1 , 12 ), NaT ])
3060
3058
result = fmt .Datetime64Formatter (x ).get_result ()
3061
3059
assert result [0 ].strip () == "2013-01-01 00:00:00"
3062
3060
assert result [1 ].strip () == "2013-01-01 12:00:00"
3063
3061
3064
3062
def test_dates (self ):
3065
- x = Series ([datetime (2013 , 1 , 1 ), datetime (2013 , 1 , 2 ), pd . NaT ])
3063
+ x = Series ([datetime (2013 , 1 , 1 ), datetime (2013 , 1 , 2 ), NaT ])
3066
3064
result = fmt .Datetime64Formatter (x ).get_result ()
3067
3065
assert result [0 ].strip () == "2013-01-01"
3068
3066
assert result [1 ].strip () == "2013-01-02"
@@ -3137,32 +3135,32 @@ def format_func(x):
3137
3135
3138
3136
class TestNaTFormatting :
3139
3137
def test_repr (self ):
3140
- assert repr (pd . NaT ) == "NaT"
3138
+ assert repr (NaT ) == "NaT"
3141
3139
3142
3140
def test_str (self ):
3143
- assert str (pd . NaT ) == "NaT"
3141
+ assert str (NaT ) == "NaT"
3144
3142
3145
3143
3146
3144
class TestDatetimeIndexFormat :
3147
3145
def test_datetime (self ):
3148
- formatted = pd .to_datetime ([datetime (2003 , 1 , 1 , 12 ), pd . NaT ]).format ()
3146
+ formatted = pd .to_datetime ([datetime (2003 , 1 , 1 , 12 ), NaT ]).format ()
3149
3147
assert formatted [0 ] == "2003-01-01 12:00:00"
3150
3148
assert formatted [1 ] == "NaT"
3151
3149
3152
3150
def test_date (self ):
3153
- formatted = pd .to_datetime ([datetime (2003 , 1 , 1 ), pd . NaT ]).format ()
3151
+ formatted = pd .to_datetime ([datetime (2003 , 1 , 1 ), NaT ]).format ()
3154
3152
assert formatted [0 ] == "2003-01-01"
3155
3153
assert formatted [1 ] == "NaT"
3156
3154
3157
3155
def test_date_tz (self ):
3158
3156
formatted = pd .to_datetime ([datetime (2013 , 1 , 1 )], utc = True ).format ()
3159
3157
assert formatted [0 ] == "2013-01-01 00:00:00+00:00"
3160
3158
3161
- formatted = pd .to_datetime ([datetime (2013 , 1 , 1 ), pd . NaT ], utc = True ).format ()
3159
+ formatted = pd .to_datetime ([datetime (2013 , 1 , 1 ), NaT ], utc = True ).format ()
3162
3160
assert formatted [0 ] == "2013-01-01 00:00:00+00:00"
3163
3161
3164
3162
def test_date_explicit_date_format (self ):
3165
- formatted = pd .to_datetime ([datetime (2003 , 2 , 1 ), pd . NaT ]).format (
3163
+ formatted = pd .to_datetime ([datetime (2003 , 2 , 1 ), NaT ]).format (
3166
3164
date_format = "%m-%d-%Y" , na_rep = "UT"
3167
3165
)
3168
3166
assert formatted [0 ] == "02-01-2003"
@@ -3226,7 +3224,7 @@ def test_tz_dateutil(self):
3226
3224
3227
3225
def test_nat_representations (self ):
3228
3226
for f in (str , repr , methodcaller ("isoformat" )):
3229
- assert f (pd . NaT ) == "NaT"
3227
+ assert f (NaT ) == "NaT"
3230
3228
3231
3229
3232
3230
def test_format_percentiles ():
0 commit comments