Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dinya
dinya / boxwhisker_equdistant_axis_ticks.ipynb
Last active December 20, 2023 08:38
Equidistant axis ticks for Holoviews boxplot chart (boxwhisker)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dinya
dinya / merg-multiindex-columns.ipynb
Created June 18, 2020 11:56
merg-multiindex-columns
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dinya
dinya / columns_as_multiindex_example.ipynb
Last active May 20, 2021 05:20
Replace flat column names with hierarchical ones in the Pandas DataFrame
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dinya
dinya / moving_average.py
Last active May 7, 2018 11:31
moving_average with numpy like pandas.DataFrame.rolling(win=n).mean()
def moving_average(a, window=3):
"""https://stackoverflow.com/a/14314054/716469
and modified to be like ``pandas.Series.rolling(window=n).mean()``:
a = np.array([1,2,3,4,5])
pd.Series(a).rolling(window=3).mean().values == moving_average(a, window=3)
"""
ret = np.cumsum(a, dtype=float)
ret[window:] = ret[window:] - ret[:-window]
ret[:window-1] = np.NaN
@dinya
dinya / cyrillic_unitsPrefix_pyqtgraph.py
Created January 7, 2018 17:36
Русификация приставок величин в pyqtgraph
"""
Русификация приставок величин в pyqtgraph
См. приставки по умолчанию в модулей pyqtgraph.functions:
SI_PREFIXES = asUnicode('yzafpnµm kMGTPEZY')
SI_PREFIXES_ASCII = 'yzafpnum kMGTPEZY' # Изменять ASCII нельзя!
См. список русских обозначений приставок СИ https://ru.wikipedia.org/wiki/%D0%9F%D1%80%D0%B8%D1%81%D1%82%D0%B0%D0%B2%D0%BA%D0%B8_%D0%A1%D0%98
"""
@dinya
dinya / get_index_from_name_xlrd.py
Created December 12, 2017 12:52
Cell names to (row, col) tuple ready for using with xlrd
def colNameToNum(name):
"""
http://cwestblog.com/2013/09/13/python-convert-excel-column-name-to-number/
"""
pow = 1
colNum = 0
for letter in name[::-1]:
colNum += (int(letter, 36) -9) * pow
pow *= 26
@dinya
dinya / get_process_list_win32.py
Created December 4, 2017 11:01
Get process list (name, pid) on win32 with python
import os
import re
def get_process_list_win32():
regexp = ur"^(?P<name>.*) \s+(?P<pid>\d+) [S|C].*$"
l = []
for i in os.popen('tasklist').readlines()[5:]:
g = re.search(regexp, i.decode("cp866").rstrip())
name = g.group("name").rstrip()
pid = g.group("pid")