25 lines
502 B
Python
25 lines
502 B
Python
# %%
|
|
from pandas import read_csv, to_datetime
|
|
|
|
df = read_csv('data-1780946658143.csv')
|
|
|
|
# %%
|
|
df.head()
|
|
|
|
# %%
|
|
# normalize timestamp to naive "yyyy-MM-dd HH:mm:ss" (drop the "+00" UTC offset)
|
|
df['timestamp'] = to_datetime(df['timestamp'], utc=True).dt.tz_localize(None)
|
|
df['timestamp'] = df['timestamp'].dt.strftime('%Y-%m-%d %H:%M:%S')
|
|
|
|
# %%
|
|
# pivot the dataframe
|
|
df = df.pivot(index='timestamp', columns='variable', values='value')
|
|
|
|
# %%
|
|
df.head()
|
|
|
|
|
|
# %%
|
|
df.to_csv('data-1780946658143-pivot.csv')
|
|
# %%
|