Skip to content

ENH: support .strftime for datetimelikes #10086

Closed
@jreback

Description

@jreback

I think Series.dt.strftime() might be useful
This is essentially just calling .format() on a datetimelike lindex (which handles NaT and such)

In [1]: dates = pd.to_datetime(pd.Series(['20010101', '20010331']), format = '%Y%m%d')

In [2]: dates
Out[2]: 
0   2001-01-01
1   2001-03-31
dtype: datetime64[ns]

In [4]: pd.DatetimeIndex(dates.values).format()
Out[4]: ['2001-01-01', '2001-03-31']

In [5]: pd.DatetimeIndex(dates.values).format(date_format='%Y%m%d')
Out[5]: ['20010101', '20010331']

Metadata

Metadata

Assignees

No one assigned

    Labels

    DatetimeDatetime data dtypeEnhancementIndexingRelated to indexing on series/frames, not to indexes themselvesOutput-Formatting__repr__ of pandas objects, to_stringStringsString extension data type and string data

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions