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 / 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)})
@LinuxIsCool
LinuxIsCool / vim_spell_quickstart.md
Last active November 20, 2023 22:30
Vim Spellcheck Quickstart

Turn Vim Spell On: :set spell

You should now see miss-spelled words underlined.

Correcting Words:

Recommend Correct Spelling (while cursor is on word): z=

@LinuxIsCool
LinuxIsCool / gradient_fill.py
Created September 23, 2023 20:32
Gradient colored area plot with holoviz
import datashader as ds
import holoviews as hv
import hvplot.pandas
import numpy as np
import pandas as pd
import panel as pn
from holoviews.operation.datashader import datashade
# Sample data