synoptic.namespace.SynopticFrame#

class synoptic.namespace.SynopticFrame(df)[source]#

Custom Polars namespace for SynopticPy DataFrames.

Parameters:

df (DataFrame)

__init__(df)[source]#
Parameters:

df (DataFrame)

Return type:

None

Methods

__init__(df)

pivot(*[, sensor_index])

Pivot a long-form SynopticPy DataFrame to wide-form.

with_local_timezone()

Convert datetime columns from UTC to local timezone.

with_network_name([which])

Provide DataFrame with network_name column.

with_wind_uv()

Provide wind_u and wind_v columns from wind speed and direction.

pivot(*, sensor_index=1, **kwargs)[source]#

Pivot a long-form SynopticPy DataFrame to wide-form.

This likely gets what you’re looking for, but it is recommended to use Polars directly to accomplish more customized pivots.

  • Long-form DataFrame has a row for each observation.

  • Wide-form DataFrame has a station variables are in their own column for each station.

Parameters:
  • sensor_index (int) – Sensor index to filter prior to the pivot.

  • **kwargs – Keyword arguments for Polars pivot.

Return type:

DataFrame

with_local_timezone()[source]#

Convert datetime columns from UTC to local timezone.

Returns:

  • DataFrame if only one unique timezone is present, else returns

  • a dict of DataFrames, one item for each timezone.

Return type:

DataFrame | dict

with_network_name(which='short')[source]#

Provide DataFrame with network_name column.

Parameters:

which ({'short', 'long'}) – Specify if the network shortname or longname is joined.

Return type:

DataFrame

with_wind_uv()[source]#

Provide wind_u and wind_v columns from wind speed and direction.

IMPORTANT Requires a wide-form DataFrame (pivoted) with columns wind_speed and wind_direction.

Return type:

DataFrame