Python pandas timestamp to string

pandas.Timestamp#

class pandas. Timestamp ( ts_input= , year=None , month=None , day=None , hour=None , minute=None , second=None , microsecond=None , tzinfo=None , * , nanosecond=None , tz=None , unit=None , fold=None ) #

Pandas replacement for python datetime.datetime object.

Timestamp is the pandas equivalent of python’s Datetime and is interchangeable with it in most cases. It’s the type used for the entries that make up a DatetimeIndex, and other timeseries oriented data structures in pandas.

Parameters : ts_input datetime-like, str, int, float

Value to be converted to Timestamp.

year, month, day int hour, minute, second, microsecond int, optional, default 0 tzinfo datetime.tzinfo, optional, default None nanosecond int, optional, default 0 tz str, pytz.timezone, dateutil.tz.tzfile or None

Time zone for time which Timestamp will have.

Unit used for conversion if ts_input is of type int or float. The valid values are ‘D’, ‘h’, ‘m’, ‘s’, ‘ms’, ‘us’, and ‘ns’. For example, ‘s’ means seconds and ‘ms’ means milliseconds.

For float inputs, the result will be stored in nanoseconds, and the unit attribute will be set as ‘ns’ .

fold , default None, keyword-only

Due to daylight saving time, one wall clock time can occur twice when shifting from summer to winter time; fold describes whether the datetime-like corresponds to the first (0) or the second time (1) the wall clock hits the ambiguous time.

There are essentially three calling conventions for the constructor. The primary form accepts four parameters. They can be passed by position or keyword.

The other two forms mimic the parameters from datetime.datetime . They can be passed by either position or keyword, but not both mixed together.

Using the primary calling convention:

This converts a datetime-like string

>>> pd.Timestamp('2017-01-01T12') Timestamp('2017-01-01 12:00:00') 

This converts a float representing a Unix epoch in units of seconds

>>> pd.Timestamp(1513393355.5, unit='s') Timestamp('2017-12-16 03:02:35.500000') 

This converts an int representing a Unix-epoch in units of seconds and for a particular timezone

>>> pd.Timestamp(1513393355, unit='s', tz='US/Pacific') Timestamp('2017-12-15 19:02:35-0800', tz='US/Pacific') 

Using the other two forms that mimic the API for datetime.datetime :

>>> pd.Timestamp(2017, 1, 1, 12) Timestamp('2017-01-01 12:00:00') 
>>> pd.Timestamp(year=2017, month=1, day=1, hour=12) Timestamp('2017-01-01 12:00:00') 

Return numpy datetime64 format in nanoseconds.

Return the day of the year.

Return the day of the year.

Return the number of days in the month.

Return the number of days in the month.

Return True if year is a leap year.

Check if the date is the last day of the month.

Check if the date is the first day of the month.

Check if date is last day of the quarter.

Check if the date is the first day of the quarter.

Return True if date is last day of the year.

Return True if date is first day of the year.

Return the quarter of the year.

The abbreviation associated with self._creso.

Return the week number of the year.

Return the week number of the year.

microsecond

Convert the underlying int64 representaton to the given unit.

Convert timezone-aware Timestamp to another time zone.

ceil (freq[, ambiguous, nonexistent])

Return a new Timestamp ceiled to this resolution.

Combine date, time into datetime with same date and time fields.

Return ctime() style string.

Return date object with same year, month and day.

Return the day name of the Timestamp with specified locale.

Return the daylight saving time (DST) adjustment.

floor (freq[, ambiguous, nonexistent])

Return a new Timestamp floored to this resolution.

int, int, int -> Construct a date from the ISO year, week number and weekday.

string -> datetime from datetime.isoformat() output

Construct a timestamp from a a proleptic Gregorian ordinal.

Transform timestamp[, tz] to tz’s local time from POSIX timestamp.

Return a named tuple containing ISO year, week number, and weekday.

Return the time formatted according to ISO 8601.

Return the day of the week represented by the date.

Return the month name of the Timestamp with specified locale.

Normalize Timestamp to midnight, preserving tz information.

Return new Timestamp object representing current time local to tz.

replace ([year, month, day, hour, minute, . ])

Implements datetime.replace, handles nanoseconds.

round (freq[, ambiguous, nonexistent])

Round the Timestamp to the specified resolution.

Return a formatted string of the Timestamp.

Function is not implemented.

Return time object with same time but with tzinfo=None.

Return POSIX timestamp as float.

Return time tuple, compatible with time.localtime().

Return time object with same time and tzinfo.

Return a numpy.datetime64 object with same precision.

Convert TimeStamp to a Julian Date.

Convert the Timestamp to a NumPy datetime64.

Return an period of which this timestamp is an observation.

Convert a Timestamp object to a native Python datetime object.

Return the current time in the local timezone.

Return proleptic Gregorian ordinal.

Convert timezone-aware Timestamp to another time zone.

Localize the Timestamp to a timezone.

Construct a timezone-aware UTC datetime from a POSIX timestamp.

Return a new Timestamp representing UTC day and time.

Return UTC time tuple, compatible with time.localtime().

Return the day of the week represented by the date.

Источник

pandas.Timestamp#

class pandas. Timestamp ( ts_input= , year=None , month=None , day=None , hour=None , minute=None , second=None , microsecond=None , tzinfo=None , * , nanosecond=None , tz=None , unit=None , fold=None ) #

Pandas replacement for python datetime.datetime object.

Timestamp is the pandas equivalent of python’s Datetime and is interchangeable with it in most cases. It’s the type used for the entries that make up a DatetimeIndex, and other timeseries oriented data structures in pandas.

Parameters ts_input datetime-like, str, int, float

Value to be converted to Timestamp.

year, month, day int hour, minute, second, microsecond int, optional, default 0 tzinfo datetime.tzinfo, optional, default None nanosecond int, optional, default 0 tz str, pytz.timezone, dateutil.tz.tzfile or None

Time zone for time which Timestamp will have.

Unit used for conversion if ts_input is of type int or float. The valid values are ‘D’, ‘h’, ‘m’, ‘s’, ‘ms’, ‘us’, and ‘ns’. For example, ‘s’ means seconds and ‘ms’ means milliseconds.

For float inputs, the result will be stored in nanoseconds, and the unit attribute will be set as ‘ns’ .

fold , default None, keyword-only

Due to daylight saving time, one wall clock time can occur twice when shifting from summer to winter time; fold describes whether the datetime-like corresponds to the first (0) or the second time (1) the wall clock hits the ambiguous time.

There are essentially three calling conventions for the constructor. The primary form accepts four parameters. They can be passed by position or keyword.

The other two forms mimic the parameters from datetime.datetime . They can be passed by either position or keyword, but not both mixed together.

Using the primary calling convention:

This converts a datetime-like string

>>> pd.Timestamp('2017-01-01T12') Timestamp('2017-01-01 12:00:00') 

This converts a float representing a Unix epoch in units of seconds

>>> pd.Timestamp(1513393355.5, unit='s') Timestamp('2017-12-16 03:02:35.500000') 

This converts an int representing a Unix-epoch in units of seconds and for a particular timezone

>>> pd.Timestamp(1513393355, unit='s', tz='US/Pacific') Timestamp('2017-12-15 19:02:35-0800', tz='US/Pacific') 

Using the other two forms that mimic the API for datetime.datetime :

>>> pd.Timestamp(2017, 1, 1, 12) Timestamp('2017-01-01 12:00:00') 
>>> pd.Timestamp(year=2017, month=1, day=1, hour=12) Timestamp('2017-01-01 12:00:00') 

Return numpy datetime64 format in nanoseconds.

Return the day of the year.

Return the day of the year.

Return the number of days in the month.

Return the number of days in the month.

Return True if year is a leap year.

Check if the date is the last day of the month.

Check if the date is the first day of the month.

Check if date is last day of the quarter.

Check if the date is the first day of the quarter.

Return True if date is last day of the year.

Return True if date is first day of the year.

Return the quarter of the year.

The abbreviation associated with self._creso.

Return the week number of the year.

Return the week number of the year.

microsecond

Convert the underlying int64 representaton to the given unit.

Convert timezone-aware Timestamp to another time zone.

ceil (freq[, ambiguous, nonexistent])

Return a new Timestamp ceiled to this resolution.

Combine date, time into datetime with same date and time fields.

Return ctime() style string.

Return date object with same year, month and day.

Return the day name of the Timestamp with specified locale.

floor (freq[, ambiguous, nonexistent])

Return a new Timestamp floored to this resolution.

int, int, int -> Construct a date from the ISO year, week number and weekday.

string -> datetime from datetime.isoformat() output

Construct a timestamp from a a proleptic Gregorian ordinal.

Transform timestamp[, tz] to tz’s local time from POSIX timestamp.

Return a 3-tuple containing ISO year, week number, and weekday.

Return the time formatted according to ISO 8610.

Return the day of the week represented by the date.

Return the month name of the Timestamp with specified locale.

Normalize Timestamp to midnight, preserving tz information.

Return new Timestamp object representing current time local to tz.

replace ([year, month, day, hour, minute, . ])

Implements datetime.replace, handles nanoseconds.

round (freq[, ambiguous, nonexistent])

Round the Timestamp to the specified resolution.

Return a formatted string of the Timestamp.

Function is not implemented.

Return time object with same time but with tzinfo=None.

Return POSIX timestamp as float.

Return time tuple, compatible with time.localtime().

Return time object with same time and tzinfo.

Return a numpy.datetime64 object with ‘ns’ precision.

Convert TimeStamp to a Julian Date.

Convert the Timestamp to a NumPy datetime64.

Return an period of which this timestamp is an observation.

Convert a Timestamp object to a native Python datetime object.

Return the current time in the local timezone.

Return proleptic Gregorian ordinal.

Convert timezone-aware Timestamp to another time zone.

Localize the Timestamp to a timezone.

Construct a timezone-aware UTC datetime from a POSIX timestamp.

Return a new Timestamp representing UTC day and time.

Return UTC time tuple, compatible with time.localtime().

Return the day of the week represented by the date.

Источник

Читайте также:  Html code highlight css
Оцените статью