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

DEPR: Passing in a string column label for DataFrame.ewm(times=...) #43265

Merged
merged 11 commits into from Sep 5, 2021

Conversation

mroeschke
Copy link
Member

@mroeschke mroeschke changed the title DEPR: Passing in a string column label for DataFrame.ewm(times=...) DEPR: Passing in a string column label for DataFrame.ewm.mean(times=...) Aug 27, 2021
@mroeschke mroeschke added Deprecate Functionality to remove in pandas Window rolling, ewma, expanding labels Aug 27, 2021
@mroeschke mroeschke changed the title DEPR: Passing in a string column label for DataFrame.ewm.mean(times=...) DEPR: Passing in a string column label for DataFrame.ewm(times=...) Aug 29, 2021
@jreback jreback added this to the 1.4 milestone Aug 30, 2021
@jreback
Copy link
Contributor

jreback commented Aug 30, 2021

umm we generally accept a column name for other things, why are we deprecating here?

@mroeschke
Copy link
Member Author

  • DEPR: dropping nuisance columns in rolling aggregations #42834 deprecated dropping nuisance column in window ops (raising a TypeError in the future)
  • A times column will always be a nuisance column because windows ops only accept numeric values and times will be a datetime64[ns], so this functionality as is will always raise a TypeError in the future

data = np.arange(10.0)
data[::2] = np.nan
df = DataFrame({"A": data, "time_col": date_range("2000", freq="D", periods=10)})
with tm.assert_produces_warning(FutureWarning, match="Specifying times"):
Copy link
Contributor

Choose a reason for hiding this comment

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

do we have any tests with times as an array (you do above in test_ewma_with_times_equal_spacing but you are also hitting the nuiscance path

Copy link
Member Author

Choose a reason for hiding this comment

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

This test passes times as an array

def test_ewma_with_times_variable_spacing(tz_aware_fixture):
tz = tz_aware_fixture
halflife = "23 days"
times = DatetimeIndex(
["2020-01-01", "2020-01-10T00:04:05", "2020-02-23T05:00:23"]
).tz_localize(tz)
data = np.arange(3)
df = DataFrame(data)
result = df.ewm(halflife=halflife, times=times).mean()
expected = DataFrame([0.0, 0.5674161888241773, 1.545239952073459])
tm.assert_frame_equal(result, expected)

@jreback jreback merged commit 31759fa into pandas-dev:master Sep 5, 2021
@jreback
Copy link
Contributor

jreback commented Sep 5, 2021

thanks @mroeschke

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecate Functionality to remove in pandas Window rolling, ewma, expanding
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants