Skip to content
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: concat/append misc fixes #13660

Merged
merged 1 commit into from
Sep 3, 2016

Conversation

sinhrks
Copy link
Member

@sinhrks sinhrks commented Jul 14, 2016

closes #13626
closes #7795

@sinhrks sinhrks added Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode API Design labels Jul 14, 2016
return to_concat, name
if len(_concat.get_dtype_kinds(to_concat)) > 1:
# ToDo: Use ABC
from pandas.tseries.api import (DatetimeIndex, PeriodIndex,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe move this to types/concat (e.g. its a concat_compat type of thing)

@jreback
Copy link
Contributor

jreback commented Jul 14, 2016

whoosh! you really cleaned this up!

had a quick look, but will look deeper later.

@sinhrks sinhrks added this to the 0.19.0 milestone Jul 15, 2016
@codecov-io
Copy link

codecov-io commented Jul 15, 2016

Current coverage is 85.26% (diff: 97.05%)

Merging #13660 into master will decrease coverage by <.01%

@@             master     #13660   diff @@
==========================================
  Files           139        139          
  Lines         50562      50506    -56   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
- Hits          43116      43066    -50   
+ Misses         7446       7440     -6   
  Partials          0          0          

Powered by Codecov. Last update 59524af...85f5d94

@jreback
Copy link
Contributor

jreback commented Jul 29, 2016

status?

- Bug in ``PeriodIndex.append`` may raises ``AttributeError`` when the result is ``object`` dtype (:issue:`13221`)
- Bug in ``CategoricalIndex.append`` may accept normal ``list`` (:issue:`13626`)
- Bug in ``pd.concat`` and ``.append`` with the same timezone get reset to UTC (:issue:`7795`)
- Bug in ``Series`` and ``DataFrame`` ``.append`` raises ``AmbiguousTimeError`` if data contains datetime near DST boundary (:issue:`14626`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this issue number is wrong

@jreback
Copy link
Contributor

jreback commented Jul 29, 2016

you seem to fix a pivot name propogation issue. is there an issue?

@jreback
Copy link
Contributor

jreback commented Aug 18, 2016

you must have just rebased this!

will look tom.

@sinhrks
Copy link
Member Author

sinhrks commented Aug 19, 2016

Yeah let me work on this first, I'll include the cleanup for CategoricalIndex in #13767.

Let you know once ready.

@sinhrks sinhrks changed the title (WIP)BUG: concat/append misc fixes BUG: concat/append misc fixes Aug 19, 2016
@sinhrks
Copy link
Member Author

sinhrks commented Aug 19, 2016

@jreback updated, and ready for review.

all inputs must be DatetimeIndex
it is used in DatetimeIndex.append also
"""
# no need to localize because internal repr will not be changed
Copy link
Contributor

@jreback jreback Aug 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should do a run-time assert that these meet the guarantees
e.g.
assert len(set([ x.tz for x in to_concat ])) == 1

@jreback
Copy link
Contributor

jreback commented Aug 26, 2016

@sinhrks looks really nice. just some minor comments and guaranetees that should specify a bit more / use asserts. ping on green.

name = None
break
if not isinstance(obj, Index):
raise TypeError('all inputs must be Index')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(a bit similar with the equals case)

Currently, we are accepting a list or tuple to be added (in case that it is a list of list, in the flat case you get an error):

In [56]: idx = pd.Index([1,2])

In [57]: idx.append([[1,2]])
Out[57]: Int64Index([1, 2, 1, 2], dtype='int64')

The docstring of append also says for other: "Index or list/tuple of indices"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_ensure_index should handle this (it might think its a MultiIndex actually), so might need to disambiguate

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, _ensure_index would convert list to Index. @jreback are you saying Index.append should accept lists?

On second thought, maybe I misread the Index.append docstring. The "Index or list/tuple of indices" can be interpreted as both as "list/tuple of Index objects" (so no guarantee to accept list as Index object) or "list of index labels".
But actually probably the first interpretation. In that case, I think this PR is OK, but @sinhrks it would maybe be good to list this in the whatsnew as change as well? (or do we regard it as a bug fix?)

Copy link
Member Author

@sinhrks sinhrks Sep 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I agree docstring intends first one. I'm adding an validation to check all elements are Index if input is list-like.

I think it is regarded as a bug fix, because it is similar to the fix which CategiricalIndex.append accepts (flat) list of labels (included in this PR).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, merging then!

@sinhrks sinhrks force-pushed the concat_cln branch 2 times, most recently from 2fabfcd to b17d8dc Compare August 29, 2016 05:24
@jreback jreback mentioned this pull request Aug 31, 2016
@jorisvandenbossche jorisvandenbossche modified the milestones: 0.19.0, 0.19.0rc Sep 1, 2016
@jorisvandenbossche jorisvandenbossche merged commit 0323336 into pandas-dev:master Sep 3, 2016
@jorisvandenbossche jorisvandenbossche modified the milestones: 0.19.0rc, 0.19.0 Sep 7, 2016
@sinhrks sinhrks deleted the concat_cln branch January 8, 2017 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG/API: Index/Series concat inconsistencies BUG: concat of objects with the same timezone get reset to UTC
4 participants