File tree Expand file tree Collapse file tree 3 files changed +6
-9
lines changed Expand file tree Collapse file tree 3 files changed +6
-9
lines changed Original file line number Diff line number Diff line change 1
- import codecs
2
1
from datetime import datetime
3
2
from textwrap import dedent
4
3
@@ -42,15 +41,15 @@ def test_to_latex_to_file_utf8_with_encoding(self):
42
41
df = DataFrame ([["au\xdf gangen" ]])
43
42
with tm .ensure_clean ("test.tex" ) as path :
44
43
df .to_latex (path , encoding = "utf-8" )
45
- with codecs . open (path , "r" , encoding = "utf-8" ) as f :
44
+ with open (path , encoding = "utf-8" ) as f :
46
45
assert df .to_latex () == f .read ()
47
46
48
47
def test_to_latex_to_file_utf8_without_encoding (self ):
49
48
# test with utf-8 without encoding option
50
49
df = DataFrame ([["au\xdf gangen" ]])
51
50
with tm .ensure_clean ("test.tex" ) as path :
52
51
df .to_latex (path )
53
- with codecs . open (path , "r" , encoding = "utf-8" ) as f :
52
+ with open (path , encoding = "utf-8" ) as f :
54
53
assert df .to_latex () == f .read ()
55
54
56
55
def test_to_latex_tabular_with_index (self ):
Original file line number Diff line number Diff line change @@ -513,19 +513,18 @@ def test_is_fsspec_url_chained():
513
513
assert not icom .is_fsspec_url ("filecache::://pandas/test.csv" )
514
514
515
515
516
- @pytest .mark .parametrize ("encoding" , [None , "utf-8" ])
517
516
@pytest .mark .parametrize ("format" , ["csv" , "json" ])
518
- def test_codecs_encoding (encoding , format ):
517
+ def test_codecs_encoding (format ):
519
518
# GH39247
520
519
expected = pd .DataFrame (
521
520
1.1 * np .arange (120 ).reshape ((30 , 4 )),
522
521
columns = pd .Index (list ("ABCD" )),
523
522
index = pd .Index ([f"i-{ i } " for i in range (30 )]),
524
523
)
525
524
with tm .ensure_clean () as path :
526
- with codecs . open (path , mode = "w" , encoding = encoding ) as handle :
525
+ with open (path , mode = "w" , encoding = "utf-8" ) as handle :
527
526
getattr (expected , f"to_{ format } " )(handle )
528
- with codecs . open (path , mode = "r" , encoding = encoding ) as handle :
527
+ with open (path , encoding = "utf-8" ) as handle :
529
528
if format == "csv" :
530
529
df = pd .read_csv (handle , index_col = 0 )
531
530
else :
Original file line number Diff line number Diff line change 1
1
from __future__ import annotations
2
2
3
- import codecs
4
3
import json
5
4
import locale
6
5
import os
@@ -143,7 +142,7 @@ def show_versions(as_json: str | bool = False) -> None:
143
142
sys .stdout .writelines (json .dumps (j , indent = 2 ))
144
143
else :
145
144
assert isinstance (as_json , str ) # needed for mypy
146
- with codecs . open (as_json , "wb " , encoding = "utf8 " ) as f :
145
+ with open (as_json , "w " , encoding = "utf-8 " ) as f :
147
146
json .dump (j , f , indent = 2 )
148
147
149
148
else :
You can’t perform that action at this time.
0 commit comments