Skip to content

BUG: Boolean indexing on an empty series loses index names #4236

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

BUG: Boolean indexing on an empty series loses index names #4236

wants to merge 1 commit into from

Conversation

miketkelly
Copy link

@jreback
Copy link
Contributor

jreback commented Jul 14, 2013

can u put tests in to check the resulting dtype
this actually may be an API change

@miketkelly
Copy link
Author

Added a check on dtype.

@hayd
Copy link
Contributor

hayd commented Aug 22, 2013

@jreback this looks reasonable to me. Think it's a bug fix rather than API change.

@mtkni Do you mind adding a Note in the release notes (docs/source/release.rst) mentioning 4235 (you'll probably have to rebase off current master first) ?

@jreback
Copy link
Contributor

jreback commented Aug 22, 2013

I think this might be fixed
as am pretty sure that in propogate names (but maybe not on empty)

@hayd
Copy link
Contributor

hayd commented Aug 22, 2013

The first test is already working in master, names propagate (however can't hurt to add test?).

This one isn't though:

        result = lib.infer_dtype(np.array([], dtype='i4'))
-        self.assertEqual(result, 'empty')
+        self.assertEqual(result, 'integer')

I get (in master):

In [10]: pd.lib.infer_dtype(np.array([], dtype='i4'))
Out[10]: 'empty'

maybe @mtkni has some thoughts.

@jreback
Copy link
Contributor

jreback commented Aug 23, 2013

actually the inference of 'empty' I don't think is actually used anywhere. I would ALWAYS return the type (and mixed) if you fall thru the loop, empty is definitly weird

@jreback
Copy link
Contributor

jreback commented Aug 23, 2013

if n == 0, then just return an inferred dtype (you have to map them, prob via the kind)

e.g.

if dtype.kind == 'i':
   return 'integer'
elif dtype.kind == 'f':
   return 'floating'
......

@hayd
Copy link
Contributor

hayd commented Aug 23, 2013

@jreback well apparently not, since moving just those 3 lines seems to do the trick. merge then?

@jreback
Copy link
Contributor

jreback commented Aug 23, 2013

@hayd ok then!

@hayd
Copy link
Contributor

hayd commented Aug 23, 2013

This passes on a rebase https://travis-ci.org/hayd/pandas/builds/10534501

@jreback Will wait on release note? Or I could pop it in to my branch.

@jreback
Copy link
Contributor

jreback commented Aug 23, 2013

@hayd whatever works for you!

@hayd
Copy link
Contributor

hayd commented Aug 23, 2013

ok, adding commit to my rebased branch and will close these.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants