Skip to content

Conversation

@msmarchena
Copy link
Contributor

@pep8speaks
Copy link

pep8speaks commented Jun 1, 2018

Hello @msmarchena! Thanks for updating the PR.

Line 2193:13: E722 do not use bare except'

Comment last updated on August 03, 2018 at 14:02 Hours UTC
Bug Fixes
~~~~~~~~~

- Bug in :func:`Dataframe.asof` that reaised ``TypeError`` when attempting to compare tz-naive and tz-aware timestamps (:issue:`21194`)
Copy link
Member

Choose a reason for hiding this comment

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

"reaised" --> "raised a"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@codecov
Copy link

codecov bot commented Jun 1, 2018

Codecov Report

Merging #21284 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@ Coverage Diff @@ ## master #21284 +/- ## ======================================= Coverage 91.85% 91.85% ======================================= Files 153 153 Lines 49546 49546 ======================================= Hits 45509 45509 Misses 4037 4037
Flag Coverage Δ
#multiple 90.25% <100%> (ø) ⬆️
#single 41.87% <0%> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/indexes/base.py 96.61% <100%> (ø) ⬆️

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 4274b84...8441881. Read the comment docs.

@jschendel jschendel added Datetime Datetime data dtype Indexing Related to indexing on series/frames, not to indexes themselves Dtype Conversions Unexpected or buggy dtype conversions labels Jun 1, 2018
@jschendel jschendel added this to the 0.23.1 milestone Jun 1, 2018
# Testing if DataFrame index preserve timezone (UTC)
df = DataFrame(data=[1, 2], index=[timestamp1, timestamp2])
result = df.asof(timestamp_internal)
expected = Series(2.0, index=RangeIndex(start=0, stop=1, step=1),
Copy link
Member

@mroeschke mroeschke Jun 1, 2018

Choose a reason for hiding this comment

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

RangeIndex isn't explicitly needed to construct the Series I think. It's created by default.

expected = Series(np.nan, index=['A', 'B'], name=3)
tm.assert_series_equal(result, expected)

def test_time_zone_aware_index(self):
Copy link
Member

Choose a reason for hiding this comment

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

If possible, could you use pytest.mark.parameterize to combine these two tests? The structure of these tests seem very similar. Looks like you might be able to param over timestamp_internal

Bug Fixes
~~~~~~~~~

- Bug in :func:`Dataframe.asof` that raised a ``TypeError`` when attempting to compare tz-naive and tz-aware timestamps (:issue:`21194`)
Copy link
Contributor

Choose a reason for hiding this comment

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

move under the Conversion section

# Testing awareness of DataFrame index considering different
# UTC and different timezone
@pytest.mark.parametrize("stamp,expected",
[(Timestamp('2018-01-01 23:22:43.325+00:00'),
Copy link
Contributor

Choose a reason for hiding this comment

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

this will have some linting errors

you can format this a bit better by doing

@pytest.mark.parameterize( "stamp, expected", [ (......), (......)]) 
@pytest.mark.parametrize("stamp,expected",
[(Timestamp('2018-01-01 23:22:43.325+00:00'),
Series(2.0,name=Timestamp('2018-01-01 23:22:43.325+00:00'))),
(Timestamp('2018-01-01 22:33:20.682+01:00'),
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add a NaT in here as well (so another case)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't understand what do you mean. Where exactly I should add a NaT?

Copy link
Contributor

Choose a reason for hiding this comment

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

equiv of the naive case, but with a non-naive Timestamp (we may already have this test, if so, just add on to it)

In [2]: df = DataFrame(data=[1, 2], ...: index=[pd.Timestamp('2018-01-01 21:00:05.001'), ...: pd.Timestamp('2018-01-01 22:35:10.550')]) ...: In [3]: df Out[3]: 0 2018-01-01 21:00:05.001 1 2018-01-01 22:35:10.550 2 In [4]: df.asof('2018-01-01 22:35:10.550') Out[4]: 0 2.0 Name: 2018-01-01 22:35:10.550000, dtype: float64 In [5]: df.asof(pd.NaT) Out[5]: 0 1.0 Name: NaT, dtype: float64 In [7]: df.asof('2018-01-01') Out[7]: 0 NaN Name: 2018-01-01 00:00:00, dtype: float64 
Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for the clarification. I will check it out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

with the fix where.values in asof_loc I have for the NaT case the following:

df Out[18]: 0 2018-01-01 21:00:05.001 1 2018-01-01 22:35:10.550 2 result=df.asof(pd.NaT) /Users/.../pandas/core/indexes/base.py:2382: FutureWarning: In the future, 'NAT < x' and 'x < NAT' will always be False. result[(locs == 0) & (where.values < self.values[first])] = -1 result Out[20]: 0 NaN Name: NaT, dtype: float64 

Is 1 really the desired value in this situation?

@pytest.mark.parametrize("stamp,expected",
[(Timestamp('2018-01-01 23:22:43.325+00:00'),
Series(2.0,name=Timestamp('2018-01-01 23:22:43.325+00:00'))),
(Timestamp('2018-01-01 22:33:20.682+01:00'),
Copy link
Contributor

Choose a reason for hiding this comment

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

equiv of the naive case, but with a non-naive Timestamp (we may already have this test, if so, just add on to it)

In [2]: df = DataFrame(data=[1, 2], ...: index=[pd.Timestamp('2018-01-01 21:00:05.001'), ...: pd.Timestamp('2018-01-01 22:35:10.550')]) ...: In [3]: df Out[3]: 0 2018-01-01 21:00:05.001 1 2018-01-01 22:35:10.550 2 In [4]: df.asof('2018-01-01 22:35:10.550') Out[4]: 0 2.0 Name: 2018-01-01 22:35:10.550000, dtype: float64 In [5]: df.asof(pd.NaT) Out[5]: 0 1.0 Name: NaT, dtype: float64 In [7]: df.asof('2018-01-01') Out[7]: 0 NaN Name: 2018-01-01 00:00:00, dtype: float64 
@jreback jreback modified the milestones: 0.23.1, 0.23.2 Jun 7, 2018
@jreback
Copy link
Contributor

jreback commented Jun 19, 2018

can you rebase and update

@jreback jreback modified the milestones: 0.23.2, 0.23.3 Jun 26, 2018
@jreback
Copy link
Contributor

jreback commented Aug 1, 2018

can u rebase

@jreback jreback removed this from the 0.23.4 milestone Aug 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Datetime Datetime data dtype Dtype Conversions Unexpected or buggy dtype conversions Indexing Related to indexing on series/frames, not to indexes themselves

7 participants