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

DOC: update the pandas.date_range() docstring #20143

Merged
merged 6 commits into from
Mar 11, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions pandas/core/indexes/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2202,29 +2202,30 @@ def _generate_regular_range(start, end, periods, offset):
def date_range(start=None, end=None, periods=None, freq='D', tz=None,
normalize=False, name=None, closed=None, **kwargs):
"""
Return a fixed frequency DatetimeIndex, with day (calendar) as the default
frequency
Return a fixed frequency DatetimeIndex.

The default frequency is day (calendar).

Parameters
----------
start : string or datetime-like, default None
Left bound for generating dates
Left bound for generating dates.
end : string or datetime-like, default None
Right bound for generating dates
Right bound for generating dates.
periods : integer, default None
Number of periods to generate
Number of periods to generate.
freq : string or DateOffset, default 'D' (calendar daily)
Frequency strings can have multiples, e.g. '5H'
Frequency strings can have multiples, e.g. '5H'.
tz : string, default None
Time zone name for returning localized DatetimeIndex, for example
Asia/Hong_Kong
Asia/Hong_Kong.
normalize : bool, default False
Normalize start/end dates to midnight before generating date range
Normalize start/end dates to midnight before generating date range.
name : string, default None
Name of the resulting DatetimeIndex
Name of the resulting DatetimeIndex.
closed : string, default None
Make the interval closed with respect to the given frequency to
the 'left', 'right', or both sides (None)
the 'left', 'right', or both sides (None).

Notes
-----
Expand All @@ -2237,6 +2238,22 @@ def date_range(start=None, end=None, periods=None, freq='D', tz=None,
Returns
-------
rng : DatetimeIndex

See Also
________
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using ---- for consistency

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ohh silly mistake! thanks for figuring it out

pandas.period_range : Return a fixed frequency PeriodIndex.
pandas.interval_range : Return a fixed frequency IntervalIndex.

Examples
--------
>>> import pandas
Copy link
Contributor

Choose a reason for hiding this comment

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

We assume that these imports are available

import pandas as pd
import numpy as np

so you can remove the import and do pd.range_range

>>> pandas.date_range('20181003', periods=2)
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 do these in iso format 2018-10-03?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will do it

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!

DatetimeIndex(['2018-10-03', '2018-10-04'], dtype='datetime64[ns]',
freq='D')

>>> pandas.date_range(start='20180101', end='20180103')
DatetimeIndex(['2018-01-01', '2018-01-02', '2018-01-03'],
dtype='datetime64[ns]', freq='D')
"""
return DatetimeIndex(start=start, end=end, periods=periods,
freq=freq, tz=tz, normalize=normalize, name=name,
Expand Down