Things that live here:

  1. Work log, where I note things I feel I'll have to Google later.
  2. Journal, very similar but about non-IT topics.
  3. Blog for rare longer-form posts (last one below).
  4. Links blog, formerly my personal wiki.

Feel free to look at what you can find here and enjoy yourself.


~17% of my country is occupied by Russia, and horrible things are happening there. You can help stop this! If you can donate - I contribute to (and fully trust) Come Back Alive and Hospitallers, but there are also other ways to help.

If you're in Germany, DHL sends packets with humanitarian help for free!

Latest posts from the Work log

Day 1619

You can add underscores to numbers in Python

TIL that for readability, x = 100000000 can be written as x = 100_000_000 etc.! Works for all kinds of numbers - ints, floats, hex etc.!1


  1. PEP 515 – Underscores in Numeric Literals | peps.python.org ↩︎

Vaex as faster pandas alternative

I have a larger-than-usual text-based dataset, need to do analysis, pandas is slow (hell, even wc -l takes 50 seconds…)

Vaex: Pandas but 1000x faster - KDnuggets - that’s a way to catch one’s attention.

Reading files

I/O Kung-Fu: get your data in and out of Vaex — vaex 4.16.0 documentation

  • vx.from_csv() reads a CSV in memory, kwargs get passed to pandas' read_csv()
  • vx.open() reads stuff lazily, but I can’t find a way to tell it that my .txt file is a CSV, and more critically - how to pass params like sep etc
  • the first two support convert= that converts stuff to things like HDFS, optionally chunk_size= is the chunk size in lines. It’ll create $N/chunk_size$ chunks and concat together at the end.
  • Ways to limit stuff:
    • nrows= is the number of rows to read, works with convert etc.
    • usecols= limits to columns by name or id, speeds up stuff too

Writing files

I can do df.export_hdf5() in vaex, but pandas can’t read that. It may be related to the opposite problem - vaex can’t open pandas HDF5 files directly, because one saves them as rows, other as columns. (See FAQ)

Doing stuff

Syntax is similar to pandas, but the documentation is somehow .. can’t put my finger on it, but I don’t enjoy it somehow.

Stupid way to find columns that are all NA

l_desc = df.describe()
# We find column names that have length_of_dataset NA values
not_empty_cols = list(l_desc.T[l_desc.T.NA!=df.count()].T.columns)
# Filter the description by them
interesting_desc = l_desc[not_empty_cols]

Using a virtual environment inside jupyter

Use Virtual Environments Inside Jupyter Notebooks & Jupter Lab [Best Practices]

Create and activate it as usual, then:

python -m ipykernel install --user --name=myenv

Timing stuff in jupyter

Difference between %time and %%time in Jupyter Notebook - Stack Overflow

  • when measuring execution time, %time refers to the line after it, %%time refers to the entire cell
  • As we remember1:
    • real/wall the ‘consensus reality’ time
    • user: the process CPU time
      • time it did stuff
    • sys: the operating system CPU time due to system calls from the process
      • interactions with CPU system r/w etc.

  1. Where’s your bottleneck? CPU time vs wallclock time ↩︎

GBIF data analysis

Format

  • GBIF Infrastructure: Data processing has a detailed description of the flow
    • occurrences.txt is an improved/cleaned/formalized verbatim.txt
    • metadata
      • meta.xml has list of all colum data types etc.
      • metadata.xml is things like download doi, license, number of rows, etc.
  • .zips are in Darwin format: FAQ
    • Because there are cases when both single and double quotes etc., and neither '/" as quotechar work.
    df = vx.read_csv(DS_LOCATION,convert="verbatim.hdf5",progress=True, sep="\t",quotechar=None,quoting=3,chunk_size=500_000)
    
    
    

Tools

Analysis

Things to try:


  1. pandas.read_csv — pandas 2.0.2 documentation ↩︎

Day 1618

pip force reinstall

TIL about pip install packagename --force-reinstall1


  1. leaflet - Steps for doing a clean uninstall and reinstall Jupyter-Lab and then ipyleaflet on Ubuntu Linux 20.04 - Stack Overflow ↩︎

jupyter notebook, lab etc. installing extensions magic, paths etc.

It all started with the menu bar disappearing on qutebrowser but not firefox: 2023-06-07-135546_897x209_scrot.png

Broke everything when trying to fix it, leading to not working vim bindings in lab. Now I have vim bindings back and can live without the menu I guess.

It took 4h of very frustrating trial and error that I don’t want to document anymore, but - the solution to get vim bindings inside jupyterlab was to use the steps for installing through jupyter of the extension for notebooks, not the recommended lab one.
Installation · lambdalisue/jupyter-vim-binding Wiki:

mkdir -p $(jupyter --data-dir)/nbextensions/vim_binding
jupyter nbextension install https://raw.githubusercontent.com/lambdalisue/jupyter-vim-binding/master/vim_binding.js --nbextensions=$(jupyter --data-dir)/nbextensions/vim_binding
jupyter nbextension enable vim_binding/vim_binding

I GUESS the issue was that previously I didn’t use --data-dir, and tried to install as-is, which led to permission hell. Me downgrading -lab at some point also helped maybe.

The recommended jupyterlab-vim package installed (through pip), was enabled, but didn’t do anything: jwkvam/jupyterlab-vim: Vim notebook cell bindings for JupyterLab.

Also, trying to install it in a clean virtualenv and then doing the same with pyenv was not part of the solution and made everything worse.

Useful bits

Getting paths for both -lab and classic:

> jupyter-lab paths
Application directory:   /home/sh/.local/share/jupyter/lab
User Settings directory: /home/sh/.jupyter/lab/user-settings
Workspaces directory: /home/sh/.jupyter/lab/workspaces

> jupyter --paths
config:
    /home/sh/.jupyter
    /home/sh/.local/etc/jupyter
    /usr/etc/jupyter
    /usr/local/etc/jupyter
    /etc/jupyter
data:
    /home/sh/.local/share/jupyter
    /usr/local/share/jupyter
    /usr/share/jupyter
runtime:
    /home/sh/.local/share/jupyter/runtime

Removing ALL packages I had locally:

pip uninstall --yes jupyter-black jupyter-client jupyter-console jupyter-core jupyter-events jupyter-lsp jupyter-server jupyter-server-terminals jupyterlab-pygments jupyterlab-server jupyterlab-vim jupyterlab-widgets
pip uninstall --yes jupyterlab nbconvert nbextension ipywidgets ipykernel nbclient nbclassic ipympl notebook 

To delete all extensions: jupyter lab clean --all

Related: 230606-1428 pip force reinstall package

Versions of everything

> pip freeze | ag "(jup|nb|ipy)"
ipykernel==6.23.1
ipython==8.12.2
ipython-genutils==0.2.0
jupyter-client==8.2.0
jupyter-contrib-core==0.4.2
jupyter-contrib-nbextensions==0.7.0
jupyter-core==5.3.0
jupyter-events==0.6.3
jupyter-highlight-selected-word==0.2.0
jupyter-nbextensions-configurator==0.6.3
jupyter-server==2.6.0
jupyter-server-fileid==0.9.0
jupyter-server-terminals==0.4.4
jupyter-server-ydoc==0.8.0
jupyter-ydoc==0.2.4
jupyterlab==3.6.4
jupyterlab-pygments==0.2.2
jupyterlab-server==2.22.1
jupyterlab-vim==0.16.0
nbclassic==1.0.0
nbclient==0.8.0
nbconvert==7.4.0
nbformat==5.9.0
scipy==1.9.3
widgetsnbextension==4.0.7

Bad vibesscreenshot of a tiny part ofhistory | grep jup

2023-06-07-140252_546x964_scrot.png

“One of the 2.5 hours I’ll never get back”, Serhii H. (2023). Oil on canvas
Kitty terminal, scrot screenshotting tool, bash.

Docker unbuffered python output to read logs live

Docker image runs a Python script that uses print() a lot, but docker logs is silent because python print() uses buffered output, and it takes minutes to show.

Solution1: tell python not to do that through an environment variable.

docker run --name=myapp -e PYTHONUNBUFFERED=1 -d myappimage

  1. Python app does not print anything when running detached in docker - Stack Overflow ↩︎

Day 1617

Useful writing cliches

  • Since then, we have witnessed an increased research interest into
  • Technical developments have gradually found their way into

Dia save antialiased PNG

I love Dia, and today I discovered that:

  • It can do layers! That work as well as expected in this context
  • To save an antialiased PNG, you have to explicitly pick “png (antialiased)” when exporting, it’s in the middle of the list and far away from all the other flavours of .png extensions

Before and after: 2023-06-05-185110_426x327_scrot.png

Day 1611 / Radar plots

The Radar chart and its caveats: “radar or spider or web chart” (c)

… are best done in plotly:

For a log axis:

fig.update_layout(
    template=None,
    polar = dict(
        radialaxis = dict(type="log"),
    )

Day 1610

Seaborn matplotlib labeling data points

Trivial option: Label data points with Seaborn & Matplotlib | EasyTweaks.com

TL;DR

for i, label in enumerate (data_labels):
    ax.annotate(label, (x_position, y_position))

BUT! Overlapping texts are sad: 2023-05-29-222417_447x384_scrot.png

SO sent me to the library Home · Phlya/adjustText Wiki and it’s awesome

fig, ax = plt.subplots()
plt.plot(x, y, 'bo')
texts = [plt.text(x[i], y[i], 'Text%s' %i, ha='center', va='center') for i in range(len(x))]
# adjust_text(texts)
adjust_text(texts, arrowprops=dict(arrowstyle='->', color='red'))

Not perfect but MUCH cleaner: 2023-05-29-222524_501x407_scrot.png 2023-05-29-222542_527x399_scrot.png

More advanced tutorial: adjustText/Examples.ipynb at master · Phlya/adjustText · GitHub

Pypy doesn’t have the latest version, which has:

Plant datasets taxonomy prep

This contains the entire list of all datasets I care about RE [[[230529-1413 Plants datasets taxonomy]]] for 230507-2308 230507-1623 Plants paper notes

REALLY NICE OVERVIEW PAPER with really good overview of the existing datasets! Frontiers | Plant recognition by AI: Deep neural nets, transformers, and kNN in deep embeddings

  • Flavia

  • Datasets | The Leaf Genie has list of leaf datasets! TODO

  • Herbarium 2021

    • Huge ds and paper linking to smaller ones - preliminarily added them to the spreadsheet
    • [[2105.13808] The Herbarium 2021 Half-Earth Challenge Dataset](https://arxiv.org/abs/2105.13808
    • <@delutioHerbarium2021HalfEarth2021 (2021) z/d>)

Next steps

Spreadsheet

  • Update it for all the sub-datasets if practical - e.g. web and friends if needed
  • Done

Datasets

  • Nice picture of who stole from whom
  • Done

Google spreadsheets basics and conditional formatting

How To Apply Conditional Formatting Across An Entire Row;

  • Basics
    • $A$1 is a direct reference to A1, that won’t move if formula is applied to a range
    • ISBLANK(..) means cell is empty
    • AND(c1,c2,...,cN), OR(c1,c2,...,cN)
  • Cond. formatting bits
    • If you need to pick the “current” cell, it’s the first cell of the range without $s
    • =$U1=1 is “if U of the current row is equal to 1” (then you can color the entire row green or whatever)
    • The order of the rules is precedence, that is rule N will overwrite N+1

Day 1607 / Black for jupyter notebook

jupyter-black · PyPI

pip install jupyter-black

To load:

%load_ext jupyter_black

It will automatically format all correct python code in the cells!

NB works much, much better with jupyterlab, in the notebook version it first executes the cell, then does black and hides cell output. It does warn about that everywhere though.

Day 1606

Seaborn how-to guide

Intro

I like seaborn but kept googling the same things and could never get any internal ‘consistency’ in it, which led to a lot of small unsystematic posts1 but I felt I was going in circles. This post is an attempt to actually read the documentation and understand the underlying logic of it all.

I’ll be using the context of my “Informationsvisualisierung und Visual Analytics 2023” HSA course’s “Aufgabe 6: Visuelle Exploration multivariater Daten”, and the dataset given for that task: UCI Machine Learning Repository: Student Performance Data Set:

This data approach student achievement in secondary education of two Portuguese schools. The data attributes include student grades, demographic, social and school related features) and it was collected by using school reports and questionnaires

Goal:

  • Mental picture of the different important architectural parts (figure/axis-level functions)
  • Clarity about where are matplotlib things exposed
  • Central place for the things I need every time I do seaborn stuff, that are currently distributed in many small posts

I’m not touching the seaborn.objects interface as the only place I’ve seen it mentioned is the official docu and I’m not sure it’s worth digging into for now.

Basics

An introduction to seaborn — seaborn 0.12.2 documentation

Themes and setting the (default) theme

# sets default theme that looks nice
# and used in all pics of the tutorial
sns.set_theme() 

Figure-level vs. axes-level functions2

Overview of seaborn plotting functions — seaborn 0.12.2 documentation:
2023-05-25-132351_654x434_scrot.png

Basics

Functions can be:

  • “axes-level”: They plot data onto a single matplotlib.axes.Axes object and return it
    • Contains the legend on the plot
    • The axes-level functions are written to act like drop-in replacements for matplotlib functions. While they add axis labels and legends automatically, they don’t modify anything beyond the axes that they are drawn into. That means they can be composed into arbitrarily-complex matplotlib figures with predictable results.

  • “figure-level”: interface through a seaborn object that manages the figure
    • (usually a FacetGrid)
    • Each module has a single figure-level function that creates/accesses axes-level ones (through the kind=xxx parameter)
    • Have the col= and row= params that automatically create subplots!
    • They take care of their own legend
    • The figure-level functions wrap their axes-level counterparts and pass the kind-specific keyword arguments (such as the bin size for a histogram) down to the underlying function. That means they are no less flexible, but there is a downside: the kind-specific parameters don’t appear in the function signature or docstring

Special cases:

  • sns.jointplot()3 has one plot with distributions around it and is a JointGrid
  • sns.pairplot()4 “visualizes every pairwise combination of variables simultaneously” and is a PairGrid

In the pic above, the figure-level functions are the blocks on top, their axes-level functions - below. (TODO: my version of that pic with the kind=xxx bits added)

Customization

Figure-level

The returned seaborn.FacetGrid can be customized in some ways (all examples here from that documentation link).

FacetGrid customization params
g.map_dataframe(sns.scatterplot, x="total_bill", y="tip")
g.set_axis_labels("Total bill ($)", "Tip ($)")
g.set_titles(col_template="{col_name} patrons", row_template="{row_name}")
g.set(xlim=(0, 60), ylim=(0, 12), xticks=[10, 30, 50], yticks=[2, 6, 10])
g.tight_layout()
g.savefig("facet_plot.png")
Accessing underlying matplotlib objects

It’s possible to access the underlying matplotlib axes:

g = sns.FacetGrid(tips, col="sex", row="time", margin_titles=True, despine=False)
g.map_dataframe(sns.scatterplot, x="total_bill", y="tip")
g.figure.subplots_adjust(wspace=0, hspace=0)
for (row_val, col_val), ax in g.axes_dict.items():
    if row_val == "Lunch" and col_val == "Female":
        ax.set_facecolor(".95")
    else:
        ax.set_facecolor((0, 0, 0, 0))

And generally access matplotlib stuff:

  • ax: The matplotlib.axes.Axes when no faceting variables are assigned.
  • axes: An array of the matplotlib.axes.Axes objects in the grid.
  • axes_dict: A mapping of facet names to corresponding matplotlib.axes.Axes.
  • figure: Access the matplotlib.figure.Figure object underlying the grid (formerly fig)
  • legend: The matplotlib.legend.Legend object, if present.
FacetGrid.set()

(Previously: 230515-2257 seaborn setting titles etc. with matplotlib set)

FacetGrid.set() is used from time to time in the tutorial (e.g. .set(title="My title"), especially in Building structured multi-plot grids) but never explicitly explained; in its documentation, there’s only “Set attributes on each subplot Axes”.

It sets attributes for each subplot’s matplotlib.axes.Axes. Useful ones are:

  • title for plot title
  • xticks,yticks

Axis-level functions + adding them to a matplotlib Figure

Axis-level functions “can be composed into arbitrarily complex matplotlib figures”.

Practically:

fig, axs = plt.subplots(2)
sns.heatmap(..., ax=axs[0])
sns.heatmap(..., ax=axs[1])

Specifying figure sizes

Documentation has an entire section on it5, mostly reprasing and stealing screenshots from it.

Axis-level

For axis-level functions, the size of the plot is determined by the size of the Figure it is part of and the axes layout in that figure. You basically use what you would do in matplotlib, relevant being:

Figure-level functions

TL;DR they have FacetGrid’s' height= and aspect=(ratio; 0.75 means 5 cells high, 4 cells wide) params that work per subplot.

Figure-level functions' size has differences:

  • the functions themselves have parameters to control the figure size (although these are actually parameters of the underlying FacetGrid that manages the figure)
  • these parameters, height and aspect, work like this: width = height * aspect
    • by default, subplots are square
  • The parameters correspond to the size of each subplot, not the overall figure

2023-05-25-140616_780x739_scrot.png

Modules

Blocks doing similar kinds of plots, each with a figure-level function and multiple axis-level ones. Listed in the API reference.6

  • Distribution plots
    • displot is the figure-level interface
      • ! $\neq$ disTplot that is deprecated
      • 2023-05-25-133527_640x125_scrot 1.png
    • histplot: Plot univariate or bivariate histograms to show distributions of datasets.
    • kdeplot :Plot univariate or bivariate distributions using kernel density estimation.
    • Less useful to me now:
      • ecdfplot: Plot empirical cumulative distribution functions.
      • rugplot: add ticks to axes with the distribution, usually in addition to other plots
  • Categorical plots
  • Regression plots
    • seaborn.relplot
    • scatterplot (with kind="scatter"; the default)
    • lineplot (with kind="line")
  • Matrix plots

And again, the already mentioned special cases, now with pictures:

  • sns.jointplot()3 has one plot with distributions around it and is a JointGrid: 2023-05-25-141619_525x515_scrot.png
  • sns.pairplot()4 “visualizes every pairwise combination of variables simultaneously” and is a PairGrid:
    2023-05-25-142405_384x394_scrot.png

Design

Marks

The parameters for marks are described better in the tutorial than I ever could: Properties of Mark objects — seaborn 0.12.2 documentation:

  • Coordinates
  • Colors
  • Marker/line styles
  • Size
  • Text
  • Align, size, offset

TODO my main remaining question is where/how do I set this? Can this be done outside the seaborn.objects interface I don’t want to learn.

Markers

  • Marker size Pass e.g. s=30 to the plotting function. (size= would be a column name)
  • Marker style: you are infinitely flexible actually! And this even goes in the legend
  • 2023-05-29-231242_885x277_scrot.png
    sns.scatterplot(
    
        style="is_available",
        # marker=MarkerStyle("o", "left"),
        markers={True: MarkerStyle("o", "left"), False: MarkerStyle("o", "right")},
    )
    

Individual questions/topics

Colors, palettes, themes etc

Setting theme and context

Controlling figure aesthetics — seaborn 0.12.2 documentation

There are five preset seaborn themes: dark, white, ticks, whitegrid, darkgrid. This picture contains the first four of the above in this order.

2023-05-30-172043_519x524_scrot.png

set_context()

Color palettes

The tutorial has this: Choosing color palettes — seaborn 0.12.2 documentation with both a theoretical basis about color and stuff, and the “how to set it in your plot”.

TL;DR sns.color_palette(PALETTE_NAME, NUM_COLORS, as_cmap=TRUE_IF_CONTINUOUS)

seaborn.color_palette() returns a list of colors or a continuous matplotlib ListedColormap colormap:

  • Accepts as palette, among other things:

    • Name of a seaborn palette (deep, muted, bright, pastel, dark, colorblind)
    • Name of matplotlib colormap
    • ‘light:<color>’, ‘dark:<color>’, ‘blend:<color>,<color>’
    • A sequence of colors in any format matplotlib accepts
  • n_colors: will truncate if it’s less than palette colors, will extend/cycle palette if it’s more

  • as_cmap - whether to return a continuous ListedColormap

  • desat

  • You can do .as_hex() to get the list as hex colors.

  • You can use it as context manager: with sns.color_palette(...): to temporarily change the current defaults.

Reversing palettes/colormaps

Matplotlib colormap + _r (tab10_r).

I needed a colormap where male is blue and female is orange, tab10 has these colors but in reversed order. This is how I got a colormap with the first two colors but reversed:

cm = sns.color_palette("tab10",2)[::-1]

First I generated a color_palette of 2 colors, then reversed the list of tuples it returned.

Individual plot types

Distributions

Plotting multiple distributions on the same subplot

  • histplot has different approaches for plotting multiple= distributions on the same plot:
    • layer (default, make them overlap)
    • stack (one on top of the other)
    • dodge (multiple small columns for each distribution): 2023-05-26-161426_401x464_scrot.png
    • fill (this beauty): 2023-05-26-161302_603x497_scrot.png
  • KDEplot can do this too! multiple=fill

Categorical

Pointplot

seaborn.pointplot

2023-05-26-184023_604x504_scrot.png

  • Errorbars:
    • To make the errorbars not-overlap, dodge=True
    • You can control their width through errwidth=
    • Statistical estimation and error bars — seaborn 0.12.2 documentation has a really cool and thorough description of the types and theory:

      The error bars around an estimate of central tendency can show one of two general things: either the range of uncertainty about the estimate or the spread of the underlying data around it. These measures are related: given the same sample size, estimates will be more uncertain when data has a broader spread. But uncertainty will decrease as sample sizes grow, whereas spread will not.

Random

Heatmaps

  • To order the rows/columns, you have to use pandas’s pd.sort_index()
  • To annotate / add text to the cells: annot=True, fmt=".1f"
  • To change the range of the colorbar/colormap , use vmin=/vmax=

Previously: Small unsystematic posts about seaborn: - Architecture-ish: - 230515-2257 seaborn setting titles etc. with matplotlib set - 230515-2016 seaborn things built on FacetGrid for easy multiple plots - Small misc: - 230428-2042 Seaborn basics - 230524-2209 Seaborn visualizing distributions and KDE plots)


  1.  ↩︎
  2. Overview of seaborn plotting functions — seaborn 0.12.2 documentation ↩︎

  3. seaborn.jointplot — seaborn 0.12.2 documentation ↩︎

  4. seaborn.pairplot — seaborn 0.12.2 documentation ↩︎

  5. Figure sizes: Overview of seaborn plotting functions — seaborn 0.12.2 documentation ↩︎

  6. Functional interface: API reference — seaborn 0.12.2 documentation ↩︎

Pandas seaborn pretty correlation code

Old code I wrote for making ds.corr() more readable, looked for it three times already ergo its place is here.

Basically: removes all small correlations, and optionally plots a colorful heatmap of that.

2023-05-25-203455_432x335_scrot.png

def plot_corr(res:pd.DataFrame):
        import seaborn as sns
        sns.heatmap(res, annot=True,fmt=".1f",cmap="coolwarm")
    
def get_biggest_corr(ds_corr: pd.DataFrame, limit: float=0.8, remove_diagonal=True, remove_nans=True,plot=False) -> pd.DataFrame:
    res =  ds_corr[(ds_corr>limit) | (ds_corr<-limit)]
    if remove_diagonal:
        np.fill_diagonal(res.values, np.nan)
    if remove_nans:
        res = res.dropna(how='all', axis=0)
        res = res.dropna(how='all', axis=1)
    if plot:
        plot_corr(res)
    else:
        return res

Day 1605 / Seaborn distributions and KDE plots

Visualizing distributions of data — seaborn 0.12.2 documentation:

  • TIL KDE means “Kernel Density Estimation”
  • common_norm=True by default applies the same normalization to the entire distribution. False scales each independently. This is critical in many cases, esp. with stat="probability"

Generally: I read the seaborn documentation, esp. the high level architecture things, and a lot of things I’ve been asking myself since forever (e.g. 230515-2257 seaborn setting titles etc. with matplotlib set) have become much clearer - and will be its own post. I love seaborn and it’s honestly worth learning to use well and systematically.

Day 1604

More matplotlib color fun with cycler package

There’s cycler, a package:

It returns cycles of dicts, finite or infinite:

from cycler import cycler

# list of colors
pal = sns.color_palette("Paired")

# `cycler` is a finite cycle, cycler() is an infinite
cols = iter(cycler(color=pal)())

# every time you need a color
my_color = next(cols)

Huggingface datasets can become pandas dataframes

Main classes:

ds = Dataset(...)
ds.set_format("pandas")

Day 1597 / matplotlib datetime axes indexing

If you have an axis indexed from timestamps and want to draw stuff there, you need to convert between datetimes and coordinates.

SO1 led me to matplotlib.dates — Matplotlib 3.7.1 documentation.

from matplotlib.dates import date2num
coordinate_float_value = date2num(your_timestamp)
# there's also num2date, etc.

Then you can do things like

g=sns.histplot(...)

g.axes.bar(x=date2num(timestamp),height=5,width=0.01)

#or 

Ref:

And, for later, gridlnes/dates fun I’ll document later maybe:

from matplotlib.dates import date2num, drange
from datetime import timedelta
import matplotlib.ticker as ticker

g = sns.lineplot(...)

# We create a grid located at midnight of each day
t_end = df_item['time.pull'].max().ceil(freq="D")
t_start = df_item['time.pull'].min().floor(freq="D")
dr_days = drange(t_start,t_end,delta=timedelta(days=1))
dr_hours = drange(t_start,t_end,delta=timedelta(hours=4))

g.axes.grid(True, axis='both',which='major')
g.axes.grid(True, axis='both',which='minor',linewidth=0.2,linestyle="--")
g.axes.xaxis.set_major_locator(ticker.FixedLocator(dr_days))
g.axes.xaxis.set_minor_locator(ticker.FixedLocator(dr_hours))

2023-05-16-002928_757x517_scrot.png


  1. python - Matplotlib datetime from event coordinates - Stack Overflow ↩︎


Latest post from Blog

Підсумки 2022

Подія року: Маша подарувала велосипед!
Жах року: Вкрали велосипед :(

Підсумків 2021 року)1

God we had no idea how happy we were.

Now playing: Let the Sunshine In - Hair2

Досягнення року: Витримав майже без втрат і майже до кінця найстресовіший рік мого життя3. Став знову писати в блог і написав кілька довгиx постів про війну і не тільки
Настрій року: болю, вини, екзистенційної моральної кризисності кожної секунди, але в той самий час - впевнености та purpose
Зустріч року: TODO
Подія року: див. “жах року”
Жах року: див. “подія року”
Країна року: Україна
Антилюдина року: Путін і 71% його співвідчизників.
Місто року: Київ, який сильно болить щоразу, як про нього думаю
Слово року: “паляниця”
Подорож року: Франція, Данія.
Веб-сервіс року: Twitter. Flightradar24, liveuamap
Колір року: темно-червоний, або чорний.
Запах року: котів, своїх та чужих
Новина року: про звільнення Херсону!
Книга року: Книга «Недержавні таємниці» Віктора Ющенко; півтора романи Стівена Кінга + перечитував все підряд, що писав Peter Watts (Rifters trilogy і т.п.).
Фільм/серіал року: Twin Peaks (перші півтора сезони)
Media N.O.S.: Bob Gymlan’s відео про Бігфута; “Сводки” команди CITeam на каналі Майкла Наки.
Пісня року: Вперше в житті нічого нового в голову не приходить. Нехай Стефанія, яку слухав двічі, та Trenulețul, яку слухав раз шість.
Заклад року: кафе через парк неподалік від квартири в Лейпцигу4; Mensa Lohmannstraße.
Напій року: “эмоционально вставляющий чай”: Turkisch Earl Gray з цукром, лимоном, імбирем, ехінацеєю, мʼятою
Їжа року: суші, “сира яєчня”
Транспорт року: велосипед; і знову Bens Express Kyiv ↔ Leipzig

Побажання собі на 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 рік:

Перемоги. Побачитися з рідними та друзями, які в Україні зараз, побувати в Україні самому. Знайти знову той спокій, який в мене був в перші два місяці цього року. Зрозуміти та вирішити питання зі здоровʼям, які нещодавно зʼявились, та знайти свій дзен з тим, що стало їх причиною. Як і минулого року - знайти свій sustainable дзен з людьми та спілкуванням з ними. Навчитися регулювати, куди направляю свою увагу і свою енергію, і навчитися істинно визначати, щО є важливим зараз і вартим моєї уваги і енергії.

Ціль на наступний рік:5

  • написати хоча б дві наукові роботи, і взагалі трошки більше Academia
  • закінчити перші два семестра магістратури і почати писати магістерську

Ну і вічнозелене: Продовжити сон, спорт, медитацію – ЦЕ ПРАЦЮЄ. (x6)

(У)


  1. Так, вирвано з контексту - my blog my rules. ↩︎

  2. “The cast of Hair performs Let the Sunshine In at the Marriage Equality Rally in NYC May 17, 2009.” ↩︎

  3. Очевидно це одна тисячна від того, наскільки адом це було для середнього українця. Є за що бути взячним Богові та Всесвіту безумовно. Але Господи. Недавно робив календарик з хронологією аду цього року - пишаюсь тим, що діагностована депресія та проблеми з тиском, шкірою, запамороченням і тонною іншого почались тільки під кінець року. ↩︎

  4. (ще раз) ↩︎

  5. Цілі з минулого року:

    • Більше писати/створювати не важливо чого (пости, бібліотеки на Github, малюнки, вірші), але make an effort, умовно пости про PKM в блог а не короткі нариси про окремі деталі (хоча краще вони, ніж взагалі нічого). Є!
    • Навчитися підтримувати спілкування з людьми навіть при жорсткій зміні shared context (how do we talk to each other if there’s no watercooler anymore?…). Згадати дзен Мерзебургу і організовувати речі. Більше спілкуватися з людьми особисто та через відеодзвінки (.. або хоча б просто по телефону), менше тексту. Коли почалась війна, було ДУЖЕ БАГАТО саме цього. Але десь з травня everything is back to normal sadly.
    • Більше свіжого повітря, подорожей, спонтанності, легкості, не економити свою енергію з ціллю потім витратити її на лежання в ліжку як не дивно, з цим теж значно краще, ніж минулого року.
     ↩︎