Skip to content

DOC: Fixed errors in pandas.DataFrame.asfreq PR07, RT02, RT03, SA04 #32362

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

Merged
merged 9 commits into from
Mar 11, 2020

Conversation

tolhassianipar
Copy link
Contributor

@tolhassianipar tolhassianipar commented Feb 29, 2020

Output of python scripts/validate_docstrings.py pandas.DataFrame.asfreq:

################################################################################
##################### Docstring (pandas.DataFrame.asfreq)  #####################
################################################################################

Convert TimeSeries to specified frequency.

Optionally provide filling method to pad/backfill missing values.

Returns the original data conformed to a new index with the specified
frequency. ``resample`` is more appropriate if an operation, such as
summarization, is necessary to represent the data at the new frequency.

Parameters
----------
freq : DateOffset or str
    Frequency DateOffset or string.
method : {'backfill'/'bfill', 'pad'/'ffill'}, default None
    Method to use for filling holes in reindexed Series (note this
    does not fill NaNs that already were present):

    * 'pad' / 'ffill': propagate last valid observation forward to next
      valid
    * 'backfill' / 'bfill': use NEXT valid observation to fill.
how : {'start', 'end'}, default end
    For PeriodIndex only (see PeriodIndex.asfreq).
normalize : bool, default False
    Whether to reset output index to midnight.
fill_value : scalar, optional
    Value to use for missing values, applied during upsampling (note
    this does not fill NaNs that already were present).

Returns
-------
converted
    Same type as caller.

See Also
--------
reindex : Conform DataFrame to new index with optional filling logic.

Notes
-----
To learn more about the frequency strings, please see `this link
<https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#offset-aliases>`__.

Examples
--------
Start by creating a series with 4 one minute timestamps.

>>> index = pd.date_range('1/1/2000', periods=4, freq='T')
>>> series = pd.Series([0.0, None, 2.0, 3.0], index=index)
>>> df = pd.DataFrame({'s':series})
>>> df
                       s
2000-01-01 00:00:00    0.0
2000-01-01 00:01:00    NaN
2000-01-01 00:02:00    2.0
2000-01-01 00:03:00    3.0

Upsample the series into 30 second bins.

>>> df.asfreq(freq='30S')
                       s
2000-01-01 00:00:00    0.0
2000-01-01 00:00:30    NaN
2000-01-01 00:01:00    NaN
2000-01-01 00:01:30    NaN
2000-01-01 00:02:00    2.0
2000-01-01 00:02:30    NaN
2000-01-01 00:03:00    3.0

Upsample again, providing a ``fill value``.

>>> df.asfreq(freq='30S', fill_value=9.0)
                       s
2000-01-01 00:00:00    0.0
2000-01-01 00:00:30    9.0
2000-01-01 00:01:00    NaN
2000-01-01 00:01:30    9.0
2000-01-01 00:02:00    2.0
2000-01-01 00:02:30    9.0
2000-01-01 00:03:00    3.0

Upsample again, providing a ``method``.

>>> df.asfreq(freq='30S', method='bfill')
                       s
2000-01-01 00:00:00    0.0
2000-01-01 00:00:30    NaN
2000-01-01 00:01:00    NaN
2000-01-01 00:01:30    2.0
2000-01-01 00:02:00    2.0
2000-01-01 00:02:30    3.0
2000-01-01 00:03:00    3.0

################################################################################
################################## Validation ##################################
################################################################################

@tolhassianipar tolhassianipar changed the title Try 2 DOC: Fixed errors in pandas.DataFrame.asfreq PR07, RT02, RT03, SA04 Feb 29, 2020
@WillAyd
Copy link
Member

WillAyd commented Feb 29, 2020

Can you merge master? I think your changed to pandas._testing were already done in #32358 so not sure why they still show here without conflict (maybe a GitHub bug?)

@tolhassianipar
Copy link
Contributor Author

Hello, sorry for late reply. I will try to fix on weekend because some reasons. Thank you.

@datapythonista
Copy link
Member

@tolhassianipar there are still unaddressed comments, not sure if you've seen it.

Also, you'll have to merge master again, since the statsmodel url is still failing sometimes, and making the CI red.

Copy link
Member

@datapythonista datapythonista left a comment

Choose a reason for hiding this comment

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

Thanks @tolhassianipar, lgtm

@WillAyd WillAyd added this to the 1.1 milestone Mar 11, 2020
@WillAyd WillAyd merged commit f33120c into pandas-dev:master Mar 11, 2020
@WillAyd
Copy link
Member

WillAyd commented Mar 11, 2020

Thanks @tolhassianipar

@tolhassianipar
Copy link
Contributor Author

Happy to join :) thanks for the guidances

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

Successfully merging this pull request may close these issues.

5 participants