Skip to main content
Version: Python

to_pd_timestamp

to_pd_timestamp converts a Java date-time to a pandas.Timestamp.

danger

Avoid deephaven.time functions in query strings. Because deephaven.time provides functions that convert between Python and Java types, every call crosses the Python-Java boundary, which slows performance. For more information, see:

Syntax

to_pd_timestamp(dt: Union[None, Instant, ZonedDateTime]) -> pandas.Timestamp

Parameters

ParameterTypeDescription
dtUnion[None, Instant, ZonedDateTime]

A Java date-time to convert to a pandas.Timestamp. If None is provided, None is returned.

Returns

Returns a pandas.Timestamp.

Examples

from deephaven.time import dh_now, to_pd_timestamp

instant = dh_now()

pd_ts = to_pd_timestamp(instant)

print(pd_ts, type(pd_ts))
from deephaven.time import dh_now, to_pd_timestamp, to_j_zdt

zdt = to_j_zdt("2024-11-04T12:22:04 ET")

pd_ts = to_pd_timestamp(zdt)

print(pd_ts, type(pd_ts))