Created
December 20, 2023 01:46
-
-
Save LinuxIsCool/c75aaf3cc745ecbae47458c8b4936125 to your computer and use it in GitHub Desktop.
Generating cadCAD style data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import pandas as pd | |
import hvplot.pandas | |
labels = list('ABC') | |
states = 4 | |
xs = 100 | |
df = pd.DataFrame({'x': len(labels)*states*list(range(xs)), 'label': [l for l in labels for _ in range(states*xs)], 'State': len(labels)*[s for s in list(range(states)) for _ in range(xs)], 'Value': 0.52+np.random.rand(len(labels)*states*xs)}) | |
df['Value'] = df.groupby(['label', 'State']).cumprod()['Value'] | |
df | |
# Observe | |
df.hvplot(x='x', y='Value', by='label', groupby='State') | |
df.hvplot(x='x', y='Value', by='State', groupby='label') | |
df.hvplot(x='x', y='Value', by='label', row='State', shared_axes=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See here for inspiration: https://discourse.holoviz.org/t/hvplot-row-not-working/6621