-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Create empty dataframe with string dtype fails #33651
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
Changes from 4 commits
82dc446
d1da8c8
66eda6a
ff26d95
92d75b7
0363ef0
5fcfed6
5ad5f8b
9e15301
e8e1ed1
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 | ||||
---|---|---|---|---|---|---|
|
@@ -83,3 +83,9 @@ def test_pandas_array_dtype(self, data): | |||||
result = pd.array(data, dtype=np.dtype(object)) | ||||||
expected = pd.arrays.PandasArray(np.asarray(data, dtype=object)) | ||||||
self.assert_equal(result, expected) | ||||||
|
||||||
def test_construct_empty_dataframe(self, dtype): | ||||||
# GH 33623 | ||||||
result = pd.DataFrame(columns=["a"], dtype=dtype) | ||||||
expected = pd.DataFrame(data=[], columns=["a"], dtype=dtype) | ||||||
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.
Suggested change
This seems a bit safer way to get the expected result. |
||||||
self.assert_frame_equal(result, expected) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -186,7 +186,9 @@ class TestInterface(base.BaseInterfaceTests): | |
|
||
|
||
class TestConstructors(base.BaseConstructorsTests): | ||
pass | ||
@pytest.mark.xfail(reason="bad is-na for empty data") | ||
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. why is this xfailed? 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.
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. Ideally we would fix this here. What needs to change? 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. need to allows values.ndim to be 0 in coerce_to_array(). 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 we instead not pass a 0-dim array to 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. I added processing to convert np.nan to [].
|
||
def test_construct_empty_dataframe(self, dtype): | ||
super().test_construct_empty_dataframe(dtype) | ||
|
||
|
||
class TestReshaping(base.BaseReshapingTests): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,7 +83,9 @@ class TestCasting(BaseInterval, base.BaseCastingTests): | |
|
||
|
||
class TestConstructors(BaseInterval, base.BaseConstructorsTests): | ||
pass | ||
@pytest.mark.xfail(reason="bad is-na for empty data") | ||
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. why is this xfailed? 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.
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. I think this would ideally fixed here. 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. if nan_dtype is dtype (IntervalDtype), can create df.
|
||
def test_construct_empty_dataframe(self, dtype): | ||
super().test_construct_empty_dataframe(dtype) | ||
|
||
|
||
class TestGetitem(BaseInterval, base.BaseGetitemTests): | ||
|
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.
I think changing this fixes the interval case
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.
This suggestion doesn't work...
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.
i've pushed this change, works on my machine. can you elaborate?
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.
Thanks @simonjayhawkins . works on my environment too.