Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Ctrl+K

pandas.Period.strftime#

Period.strftime(fmt)#

Returns a formatted string representation of thePeriod.

fmt must beNone or a string containing one or several directives.WhenNone, the format will be determined from the frequency of the Period.The method recognizes the same directives as thetime.strftime()function of the standard Python distribution, as well as the specificadditional directives%f,%F,%q,%l,%u,%n.(formatting & docs originally from scikits.timeries).

Directive

Meaning

Notes

%a

Locale’s abbreviated weekdayname.

%A

Locale’s full weekday name.

%b

Locale’s abbreviated monthname.

%B

Locale’s full month name.

%c

Locale’s appropriate date andtime representation.

%d

Day of the month as a decimalnumber [01,31].

%f

‘Fiscal’ year without acentury as a decimal number[00,99]

(1)

%F

‘Fiscal’ year with a centuryas a decimal number

(2)

%H

Hour (24-hour clock) as adecimal number [00,23].

%I

Hour (12-hour clock) as adecimal number [01,12].

%j

Day of the year as a decimalnumber [001,366].

%m

Month as a decimal number[01,12].

%M

Minute as a decimal number[00,59].

%p

Locale’s equivalent of eitherAM or PM.

(3)

%q

Quarter as a decimal number[1,4]

%S

Second as a decimal number[00,61].

(4)

%l

Millisecond as a decimal number[000,999].

%u

Microsecond as a decimal number[000000,999999].

%n

Nanosecond as a decimal number[000000000,999999999].

%U

Week number of the year(Sunday as the first day ofthe week) as a decimal number[00,53]. All days in a newyear preceding the firstSunday are considered to be inweek 0.

(5)

%w

Weekday as a decimal number[0(Sunday),6].

%W

Week number of the year(Monday as the first day ofthe week) as a decimal number[00,53]. All days in a newyear preceding the firstMonday are considered to be inweek 0.

(5)

%x

Locale’s appropriate daterepresentation.

%X

Locale’s appropriate timerepresentation.

%y

Year without century as adecimal number [00,99].

%Y

Year with century as a decimalnumber.

%Z

Time zone name (no charactersif no time zone exists).

%%

A literal'%' character.

Notes

  1. The%f directive is the same as%y if the frequency isnot quarterly.Otherwise, it corresponds to the ‘fiscal’ year, as defined bytheqyear attribute.

  2. The%F directive is the same as%Y if the frequency isnot quarterly.Otherwise, it corresponds to the ‘fiscal’ year, as defined bytheqyear attribute.

  3. The%p directive only affects the output hour fieldif the%I directive is used to parse the hour.

  4. The range really is0 to61; this accounts for leapseconds and the (very rare) double leap seconds.

  5. The%U and%W directives are only used in calculationswhen the day of the week and the year are specified.

Examples

>>>frompandasimportPeriod>>>a=Period(freq='Q-JUL',year=2006,quarter=1)>>>a.strftime('%F-Q%q')'2006-Q1'>>># Output the last month in the quarter of this date>>>a.strftime('%b-%Y')'Oct-2005'>>>>>>a=Period(freq='D',year=2001,month=1,day=1)>>>a.strftime('%d-%b-%Y')'01-Jan-2001'>>>a.strftime('%b.%d, %Y was a %A')'Jan. 01, 2001 was a Monday'

[8]ページ先頭

©2009-2025 Movatter.jp