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

WIP: DatetimeArray+TimedeltaArray #23415

Closed
wants to merge 10 commits into from

Conversation

jbrockmendel
Copy link
Member

I'll be traveling later this week, so trying to get a few things online before disappearing.

So far this just implements take and concat_same_type. Tests are taken from an older mothballed PR, so are pretty duplicative, need to be cleaned up.

@pep8speaks
Copy link

pep8speaks commented Oct 30, 2018

Hello @jbrockmendel! Thanks for updating the PR.

Line 217:5: E265 block comment should start with '# '
Line 218:5: E265 block comment should start with '# '
Line 219:5: E265 block comment should start with '# '
Line 220:5: E265 block comment should start with '# '

Comment last updated on November 11, 2018 at 17:44 Hours UTC

@codecov
Copy link

codecov bot commented Oct 30, 2018

Codecov Report

Merging #23415 into master will decrease coverage by 0.06%.
The diff coverage is 84.61%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #23415      +/-   ##
==========================================
- Coverage   92.24%   92.17%   -0.07%     
==========================================
  Files         161      161              
  Lines       51278    51223      -55     
==========================================
- Hits        47299    47216      -83     
- Misses       3979     4007      +28
Flag Coverage Δ
#multiple 90.61% <84.61%> (-0.02%) ⬇️
#single 42.21% <21.15%> (-0.08%) ⬇️
Impacted Files Coverage Δ
pandas/core/arrays/period.py 97.49% <100%> (-0.6%) ⬇️
pandas/core/arrays/datetimes.py 97.09% <77.77%> (-1.34%) ⬇️
pandas/core/arrays/datetimelike.py 93.43% <78.57%> (-2.48%) ⬇️
pandas/core/arrays/timedeltas.py 94.02% <88.88%> (+0.24%) ⬆️
pandas/io/feather_format.py 77.14% <0%> (-12.61%) ⬇️
pandas/io/parquet.py 73.72% <0%> (-11.04%) ⬇️
pandas/io/formats/html.py 90.68% <0%> (-2.47%) ⬇️
pandas/core/indexes/range.py 95.77% <0%> (-1.56%) ⬇️
pandas/core/indexes/period.py 91.04% <0%> (-1.22%) ⬇️
... and 77 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3230468...cd63892. Read the comment docs.

@sinhrks sinhrks added Datetime Datetime data dtype Timedelta Timedelta data type labels Oct 30, 2018
@jorisvandenbossche
Copy link
Member

Quick comment: IMO it is not needed to write tests for basic functioning of eg _concat_same_type or take, this is already covered by the base extension tests.
(for take, there is of course some specific handling of the fill_value, which should be tested specifically for datetime-likes)

@jorisvandenbossche jorisvandenbossche added ExtensionArray Extending pandas with custom dtypes or arrays. Refactor Internal refactoring of code labels Oct 30, 2018
@jorisvandenbossche jorisvandenbossche added this to the 0.24.0 milestone Oct 30, 2018
@jorisvandenbossche
Copy link
Member

@jbrockmendel What is the status of this, or how does it related to the other PRs? Is this still something you plan to continue working on (so worth to review), or not?

@jbrockmendel
Copy link
Member Author

This is essentially orthogonal to the other PRs ATM. It has been in hold in part because I expect you would be -1 on implementing any parts of the EA interface without implementing all of them. If that expectation is incorrect, then I would probably add __repr__ and other easily-reviewed needed-eventually methods.

@jorisvandenbossche
Copy link
Member

jorisvandenbossche commented Nov 5, 2018

My expectation (from the title and original description) was that you would further expand this PR to cover the full EA interface, but that is not the plan?

@jbrockmendel
Copy link
Member Author

My expectation was that you would further expand this PR to cover the full EA interface, but that is not the plan?

That was more or less the plan (the "more or less" being that I would have been OK with splitting it into chunks). Besides the trouble with actually implementing this, we've got pieces of this conversation going on in at least four threads, and this is the one I'm most comfortable with letting lie dormant.

pandas/core/arrays/datetimelike.py Show resolved Hide resolved
return cls._simple_new(values, freq=freq)

def copy(self, deep=False):
# TODO: should `deep` determine whether we copy self.asi8?
Copy link
Contributor

Choose a reason for hiding this comment

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

yes like

values = self.asi8
if deep:
    values = values.copy()
....


# Following how PeriodArray does this
# TODO: ignoring `type`?
def view(self, dtype=None, type=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this so complicated? do we really need this method?

Copy link
Member Author

Choose a reason for hiding this comment

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

I implemented this because tests were raising AttributeErrors asking for it.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah we really can' support .view generally with EA. maybe just leave this on Index.

Copy link
Member Author

Choose a reason for hiding this comment

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

Really this PR is still sufficiently early in the "WIP" phase it isn't worth spending much time on ATM.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok sure


@classmethod
def _concat_same_type(cls, to_concat):
freqs = {x.freq for x in to_concat}
Copy link
Contributor

Choose a reason for hiding this comment

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

you do this freq dance a few times, maybe a helper function?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll take a look.

@@ -4242,6 +4242,9 @@ def _try_cast(arr, take_fast_path):
not (is_iterator(subarr) or
isinstance(subarr, np.ndarray))):
subarr = construct_1d_object_array_from_listlike(subarr)
elif type(subarr).__name__ == "DatetimeArray":
Copy link
Contributor

Choose a reason for hiding this comment

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

woa??

Copy link
Member Author

Choose a reason for hiding this comment

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

Yah this is a kludge that should have gotten changed to an isinstance(subarr, ABCDatetimeArray) before pushing

@jbrockmendel
Copy link
Member Author

The useful parts of this are now a strict subset of #23643. Closing.

@jbrockmendel jbrockmendel deleted the dlike_ea branch November 12, 2018 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype ExtensionArray Extending pandas with custom dtypes or arrays. Refactor Internal refactoring of code Timedelta Timedelta data type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants