Skip to content

Instantly share code, notes, and snippets.

View find_nearest.py
def find_nearest(value,
array,
return_value=False):
"""Find nearest value in a numpy array
Parameters
----------
value : value to search for
array : array to search in, should be sorted.
View data-normalisation.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kidpixo
kidpixo / CovarianceThreshold_Transformer.py
Last active Feb 20, 2019
A scikit-learn transformer for extracting low correlation continuous features.
View CovarianceThreshold_Transformer.py
import sklearn
class CorrelationThreshold(sklearn.base.BaseEstimator, sklearn.base.TransformerMixin):
"""A tranformer for combining low correlation on continous features.
This Transformer returns only features that have Pearson product-moment correlation coefficients
above a threshold value, default 0.99.
After fit, some data is available :
`get_statistics()` : returns information on the correlation matrix (max,min,percentiles)
View adventofcode_day3.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kidpixo
kidpixo / rpm_yum_install_in_user_home_for_non-admins.sh
Created Oct 2, 2018
small script to emulate yum install in user home for non-admins of rmp
View rpm_yum_install_in_user_home_for_non-admins.sh
#!/bin/bash
# see : rpm - yum install in user home for non-admins
# http://unix.stackexchange.com/questions/61283/yum-install-in-user-home-for-non-admins
# Usage:
# 0. check your architecture
# uname -a
# Linux laser.pe.ba.dlr.de 3.10.0-514.21.1.el7.x86_64 #1 SMP Sat Apr 22 02:41:35 EDT 2017 x86_64 x86_64 x86_64 GNU/Linux
#
# 1. search a packet for your architecture.
# Example: gnu parallel for x86_64 architecture.
View regex_question.py
# how to change this:
pid = Column(Integer, primary_key=True)
SOFTWARE_VERSION = Column('software_version',Float)
SPACECRAFT_CLOCK_START_COUNT = Column('spacecraft_clock_start_count',Float)
ALONG_TRACK_FOOTPRINT_SIZE = Column('along_track_footprint_size',Float)
PACKET_SUBSECONDS = Column('packet_subseconds',Integer)
Partial_Data = Column('partial_data',Integer)
Temperature_2 = Column('temperature_2',Integer)
TEMP_2 = Column('temp_2',Float)
SPICE_Version_Epoch = Column('spice_version_epoch',Integer)
View custom.css
/* *************************************************************************************** */
/* this should be in ~/.jupyter/custom/custom.css and
/* *************************************************************************************** */
.container { width:99% !important; }
/* Uncomment to use a custom font */
/* div#notebook, div.CodeMirror, div.output_area pre, div.output_wrapper, div.prompt {
font-family: 'Roboto Mono', monospace !important;
font-weight: normal !important;
@kidpixo
kidpixo / .gitignore
Last active Jul 6, 2018
Small/basic python3.6 script to read,import in pandas and export in multiple format your smartctl status.
View .gitignore
*.db
*.html
*.xls
*.xslx
View extract_list_to_dict.py
# goal : extract a list of string based on first char.
# use case : parsing argument given to a cli command.
from itertools import groupby
arg_tags = ['!dog', 'dog', '!Monty'] # input values
{{1:'exclude',0:'include'}[k]: # key value from dict
list(g) # values from groupby
for k,g in groupby(
sorted(
arg_tags, # argument to sort
key=lambda i : i[0] # based on first char