-
Notifications
You must be signed in to change notification settings - Fork 54
Closed
Milestone
Description
from datetime import datetime, timedelta, timezone
import numpy as np
import pandas as pd
from lets_plot import *
LetsPlot.setup_html()
def squiggle(x):
return np.sin(3*x) / (x * (np.cos(x) + 2))
N=50
ys = [squiggle(x) for x in xs ]
# Berlin DST transition: March 30, 2025 at 2:00 AM
# Cover ±3 days: March 27 - April 2, 2025 (6 days total)
# Generate equally spaced UNIX timestamps (in seconds)
start_timestamp = datetime(2025, 3, 27, 0, 0, tzinfo=timezone.utc).timestamp()
end_timestamp = datetime(2025, 4, 2, 23, 59, tzinfo=timezone.utc).timestamp()
unix_timestamps = np.linspace(start_timestamp, end_timestamp, N)
# Convert to pandas datetime series with Berlin timezone
xs_datetime = pd.to_datetime(unix_timestamps, unit='s', utc=True).tz_convert('Europe/Berlin')
df = pd.DataFrame({
'xs': xs_datetime,
'ys': ys
})
p = ggplot(data = df, mapping=aes('xs', 'ys')) + geom_line()
p
p + xlim(
pd.Timestamp('2025-03-29 23:00:00', tz='Europe/Berlin'),
pd.Timestamp('2025-03-30 08:00:00', tz='Europe/Berlin')
)

