Skip to content

Commit 89058bf

Browse files
authored
Merge branch 'main' into autofilter-feature
2 parents 3e8d5e3 + 8f359f8 commit 89058bf

File tree

3 files changed

+56
-32
lines changed

3 files changed

+56
-32
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ If you are simply looking to start working with the pandas codebase, navigate to
179179

180180
You can also triage issues which may include reproducing bug reports, or asking for vital information such as version numbers or reproduction instructions. If you would like to start triaging issues, one easy way to get started is to [subscribe to pandas on CodeTriage](https://www.codetriage.com/pandas-dev/pandas).
181181

182-
Or maybe through using pandas you have an idea of your own or are looking for something in the documentation and thinking ‘this can be improved’...you can do something about it!
182+
Or maybe through using pandas you have an idea of your own or are looking for something in the documentation and thinking ‘this can be improved’... you can do something about it!
183183

184184
Feel free to ask questions on the [mailing list](https://groups.google.com/forum/?fromgroups#!forum/pydata) or on [Slack](https://pandas.pydata.org/docs/dev/development/community.html?highlight=slack#community-slack).
185185

pandas/tests/frame/methods/test_join.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,3 +575,27 @@ def test_frame_join_tzaware(self):
575575

576576
tm.assert_index_equal(result.index, expected)
577577
assert result.index.tz.key == "US/Central"
578+
579+
def test_frame_join_categorical_index(self):
580+
# GH 61675
581+
cat_data = pd.Categorical(
582+
[3, 4],
583+
categories=pd.Series([2, 3, 4, 5], dtype="Int64"),
584+
ordered=True,
585+
)
586+
values1 = "a b".split()
587+
values2 = "foo bar".split()
588+
df1 = DataFrame({"hr": cat_data, "values1": values1}).set_index("hr")
589+
df2 = DataFrame({"hr": cat_data, "values2": values2}).set_index("hr")
590+
df1.columns = pd.CategoricalIndex([4], dtype=cat_data.dtype, name="other_hr")
591+
df2.columns = pd.CategoricalIndex([3], dtype=cat_data.dtype, name="other_hr")
592+
593+
df_joined = df1.join(df2)
594+
expected = DataFrame(
595+
{"hr": cat_data, "values1": values1, "values2": values2}
596+
).set_index("hr")
597+
expected.columns = pd.CategoricalIndex(
598+
[4, 3], dtype=cat_data.dtype, name="other_hr"
599+
)
600+
601+
tm.assert_frame_equal(df_joined, expected)

pandas/tests/io/parser/common/test_file_buffer_url.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -97,25 +97,25 @@ def test_nonexistent_path(all_parsers):
9797

9898
@pytest.mark.skipif(WASM, reason="limited file system access on WASM")
9999
@td.skip_if_windows # os.chmod does not work in windows
100-
def test_no_permission(all_parsers):
100+
def test_no_permission(all_parsers, temp_file):
101101
# GH 23784
102102
parser = all_parsers
103103

104104
msg = r"\[Errno 13\]"
105-
with tm.ensure_clean() as path:
106-
os.chmod(path, 0) # make file unreadable
105+
path = temp_file
106+
os.chmod(path, 0) # make file unreadable
107107

108-
# verify that this process cannot open the file (not running as sudo)
109-
try:
110-
with open(path, encoding="utf-8"):
111-
pass
112-
pytest.skip("Running as sudo.")
113-
except PermissionError:
108+
# verify that this process cannot open the file (not running as sudo)
109+
try:
110+
with open(path, encoding="utf-8"):
114111
pass
112+
pytest.skip("Running as sudo.")
113+
except PermissionError:
114+
pass
115115

116-
with pytest.raises(PermissionError, match=msg) as e:
117-
parser.read_csv(path)
118-
assert path == e.value.filename
116+
with pytest.raises(PermissionError, match=msg) as e:
117+
parser.read_csv(path)
118+
assert str(path.resolve()) == e.value.filename
119119

120120

121121
@pytest.mark.parametrize(
@@ -269,19 +269,19 @@ def test_internal_eof_byte(all_parsers):
269269
tm.assert_frame_equal(result, expected)
270270

271271

272-
def test_internal_eof_byte_to_file(all_parsers):
272+
def test_internal_eof_byte_to_file(all_parsers, temp_file):
273273
# see gh-16559
274274
parser = all_parsers
275275
data = b'c1,c2\r\n"test \x1a test", test\r\n'
276276
expected = DataFrame([["test \x1a test", " test"]], columns=["c1", "c2"])
277277
path = f"__{uuid.uuid4()}__.csv"
278278

279-
with tm.ensure_clean(path) as path:
280-
with open(path, "wb") as f:
281-
f.write(data)
279+
path2 = temp_file.parent / path
280+
with open(path2, "wb") as f:
281+
f.write(data)
282282

283-
result = parser.read_csv(path)
284-
tm.assert_frame_equal(result, expected)
283+
result = parser.read_csv(path2)
284+
tm.assert_frame_equal(result, expected)
285285

286286

287287
def test_file_handle_string_io(all_parsers):
@@ -372,7 +372,7 @@ def test_read_csv_file_handle(all_parsers, io_class, encoding):
372372
assert not handle.closed
373373

374374

375-
def test_memory_map_compression(all_parsers, compression):
375+
def test_memory_map_compression(all_parsers, compression, temp_file):
376376
"""
377377
Support memory map for compressed files.
378378
@@ -381,16 +381,16 @@ def test_memory_map_compression(all_parsers, compression):
381381
parser = all_parsers
382382
expected = DataFrame({"a": [1], "b": [2]})
383383

384-
with tm.ensure_clean() as path:
385-
expected.to_csv(path, index=False, compression=compression)
384+
path = temp_file
385+
expected.to_csv(path, index=False, compression=compression)
386386

387-
if parser.engine == "pyarrow":
388-
msg = "The 'memory_map' option is not supported with the 'pyarrow' engine"
389-
with pytest.raises(ValueError, match=msg):
390-
parser.read_csv(path, memory_map=True, compression=compression)
391-
return
387+
if parser.engine == "pyarrow":
388+
msg = "The 'memory_map' option is not supported with the 'pyarrow' engine"
389+
with pytest.raises(ValueError, match=msg):
390+
parser.read_csv(path, memory_map=True, compression=compression)
391+
return
392392

393-
result = parser.read_csv(path, memory_map=True, compression=compression)
393+
result = parser.read_csv(path, memory_map=True, compression=compression)
394394

395395
tm.assert_frame_equal(
396396
result,
@@ -442,12 +442,12 @@ def test_context_manageri_user_provided(all_parsers, datapath):
442442

443443

444444
@skip_pyarrow # ParserError: Empty CSV file
445-
def test_file_descriptor_leak(all_parsers):
445+
def test_file_descriptor_leak(all_parsers, temp_file):
446446
# GH 31488
447447
parser = all_parsers
448-
with tm.ensure_clean() as path:
449-
with pytest.raises(EmptyDataError, match="No columns to parse from file"):
450-
parser.read_csv(path)
448+
path = temp_file
449+
with pytest.raises(EmptyDataError, match="No columns to parse from file"):
450+
parser.read_csv(path)
451451

452452

453453
def test_memory_map(all_parsers, csv_dir_path):

0 commit comments

Comments
 (0)