Skip to content

Instantly share code, notes, and snippets.

View LinuxIsCool's full-sized avatar
💭
Preparing the ship.

Shawn Anderson LinuxIsCool

💭
Preparing the ship.
View GitHub Profile
@LinuxIsCool
LinuxIsCool / market_sim_stream.py
Created April 26, 2024 17:53
Simple data generator with streamz
from streamz import Stream
def market_step(market_inputs):
return {'market_movement': market_inputs['market_movement']}
def write(x):
print(x)
def f(n=5):
source = Stream(asynchronous=True) # Configure the stream for asynchronous operation
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@LinuxIsCool
LinuxIsCool / hvplot_legends.py
Created March 26, 2024 16:13
Modifying legend positions in hvplot
import pandas as pd
import hvplot.pandas
df = pd.DataFrame({'x':range(10),'y':range(10), 'z':range(10)})
df.hvplot.step(x='x').opts(legend_position='top_left')
df = pd.DataFrame({'x':range(10),'y':range(10),'z':range(10)})
df.hvplot.line(x='x', legend='left')
@LinuxIsCool
LinuxIsCool / panel_param_hvplot_resettable.py
Created March 24, 2024 00:39
Python Param Panel with Resettable Button
import param as pm
import panel as pn
import hvplot.pandas
import pandas as pd
import numpy as np
pn.extension()
class ResettableParameterized(pm.Parameterized):
def _reset(self):
with pm.parameterized.batch_call_watchers(self):
@LinuxIsCool
LinuxIsCool / panel_param_hvplot.py
Created March 24, 2024 00:28
Testing Python Panel Param Hvplot Interactive Plotting
import param as pm
import panel as pn
import hvplot.pandas
import pandas as pd
import numpy as np
pn.extension()
class Test(pm.Parameterized):
y = pm.Number(10, bounds=(0,20))
def view(self):
@LinuxIsCool
LinuxIsCool / panel_param_accordian.md
Created February 7, 2024 18:34
Hvplot Panel Param example with Accordian

Nice little interactive data widget with accordion example.

import panel as pn
import param as pm
import numpy as np
import pandas as pd
import hvplot.pandas

class SimplePlotExample(pm.Parameterized):
@LinuxIsCool
LinuxIsCool / c_i_tab.md
Created February 2, 2024 22:46
Differentiate `<C-i>` from `<TAB>` in alacritty
@LinuxIsCool
LinuxIsCool / print_dataframe_names.md
Created December 30, 2023 03:14
Print names with your dataframes.

I'm looking for a canonical way of displaying the name property of dataframes when printing or logging.

Here is a module that overrides print with a method that prints dataframes with their names if they have the name property, and prints normally otherwise.

import builtins

import pandas as pd
@LinuxIsCool
LinuxIsCool / cadcad_gen.py
Created December 20, 2023 01:46
Generating cadCAD style data
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)})