pandas range
时间: 2023-08-05 20:03:15 浏览: 111
Pandas does not have a direct equivalent to the `range` function in Python. However, you can generate a range of values using the `pd.date_range` or `pd.timedelta_range` functions.
For example, to generate a range of dates, you can use the `pd.date_range` function. Here's an example:
```python
import pandas as pd
dates = pd.date_range(start='2022-01-01', end='2022-01-10')
print(dates)
```
This will output a `DatetimeIndex` object containing a range of dates from January 1, 2022, to January 10, 2022.
Similarly, you can use the `pd.timedelta_range` function to generate a range of timedeltas. Here's an example:
```python
import pandas as pd
time_range = pd.timedelta_range(start='1 day', end='5 days', freq='1 day')
print(time_range)
```
This will output a `TimedeltaIndex` object containing a range of timedeltas from 1 day to 5 days, with a frequency of 1 day.
阅读全文