Skip to content

Issue - 27482 : fixed isnull attribute for type objects #27980

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.25.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Indexing
Missing
^^^^^^^

-
- Fixed bug where object with no data attribute were not being caught (:issue:`27482`)
-
-

Expand Down
12 changes: 9 additions & 3 deletions pandas/core/dtypes/missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
missing types & inference
"""
import numpy as np

from pandas._config import get_option

from pandas._libs import lib
Expand Down Expand Up @@ -46,7 +45,6 @@
isposinf_scalar = libmissing.isposinf_scalar
isneginf_scalar = libmissing.isneginf_scalar


def isna(obj):
"""
Detect missing values for an array-like object.
Expand Down Expand Up @@ -128,6 +126,12 @@ def isna(obj):


def _isna_new(obj):
try:
# If any object doesn't have an attribute data
if obj._data == None:
return False
except:
pass
if is_scalar(obj):
return libmissing.checknull(obj)
# hack (for now) because MI registers as ndarray
Expand All @@ -152,6 +156,7 @@ def _isna_new(obj):
elif hasattr(obj, "__array__"):
return _isna_ndarraylike(np.asarray(obj))
else:
print("Test")
return obj is None


Expand Down Expand Up @@ -222,8 +227,10 @@ def _isna_ndarraylike(obj):
else:
values = obj


dtype = values.dtype


if is_extension:
if isinstance(obj, (ABCIndexClass, ABCSeries)):
values = obj._values
Expand Down Expand Up @@ -254,7 +261,6 @@ def _isna_ndarraylike(obj):
# box
if isinstance(obj, ABCSeries):
result = obj._constructor(result, index=obj.index, name=obj.name, copy=False)

return result


Expand Down
19 changes: 19 additions & 0 deletions scripts/tests/test_27482.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import pandas as pd
import pytest
import unittest

class TestStringMethods(unittest.TestCase):

def test1(self):
x = pd.Series([1,2,3,4])
xt = type(x)
assert pd.isnull(xt)==False,"Passed"

def test2(self):
y = pd.DataFrame({"col": [1,2,3,4]})
yt = type(y)
assert pd.isnull(yt)==False,"Passed"


if __name__ == '__main__':
unittest.main()