-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: pathlib.Path in io #16292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: pathlib.Path in io #16292
Changes from 1 commit
cff750f
adf77f0
ae22641
086a11b
3dda8bc
1ecbe0d
8a4e291
9293b14
83415a7
577796e
f135e32
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -314,6 +314,8 @@ def _get_handle(path_or_buf, mode, encoding=None, compression=None, | |
|
||
handles = list() | ||
f = path_or_buf | ||
# Convert pathlib.Path/py.path.local or string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you add a blank line |
||
path_or_buf = _stringify_path(path_or_buf) | ||
is_path = isinstance(path_or_buf, compat.string_types) | ||
|
||
if compression: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -267,6 +267,7 @@ def python_unpickler(path): | |
compare_element(result, expected, typ) | ||
|
||
|
||
|
||
def test_pickle_v0_14_1(): | ||
|
||
cat = pd.Categorical(values=['a', 'b', 'c'], ordered=False, | ||
|
@@ -299,6 +300,15 @@ def test_pickle_v0_15_2(): | |
tm.assert_categorical_equal(cat, pd.read_pickle(pickle_path)) | ||
|
||
|
||
def test_pickle_path_pathlib(): | ||
tm._skip_if_no_pathlib() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. instead of making a specific test can u add a general routine like we have for round_trip_pickle There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and then use it here ideally add tests for all of the io functions (and xfail id they don't work) and test for localpath as well There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, let me know if what I just pushed is what you had in mind and I'll add to other io functions There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep exactly like this! maybe put a little docs in the testing file above these 3 tests routines. |
||
from pathlib import Path | ||
with tm.ensure_clean('pkl') as path: | ||
df = pd.DataFrame({'a': [1, 2, 3]}) | ||
df.to_pickle(Path(path)) | ||
result = pd.read_pickle(Path(path)) | ||
tm.assert_frame_equal(df, result) | ||
|
||
# --------------------- | ||
# test pickle compression | ||
# --------------------- | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
localpath too?