Skip to content

Instantly share code, notes, and snippets.

View bhishanpdl's full-sized avatar

Bhishan Poudel bhishanpdl

View GitHub Profile
%%bash
cat > out.csv << EOL
lines
EOL
def clean_data(data):
"""
Clean the pandas dataframe.
data: pandas dataframe
return: cleaned dataframe
1. Make column names lowercase and underscored.
ax = users['gender'].value_counts().plot(kind='bar')
for p in ax.patches:
ax.annotate(np.round(p.get_height(), decimals=2),
(p.get_x()+p.get_width()/2.,
p.get_height()), ha='center',
va='center', xytext=(0, 10),
textcoords='offset points')
ax = users['gender'].value_counts().plot(kind='barh')
for p in ax.patches:
ax.annotate(str(int(p.get_width())), (p.get_x() + p.get_width(), p.get_y()), xytext=(-2, 4), textcoords='offset points', horizontalalignment='right')
@bhishanpdl
bhishanpdl / fits_combine_jedisim_two.py
Created September 4, 2018 14:10
Add two fits files from jedisim outputs with jedism settings headers.
#!python
# -*- coding: utf-8 -*-#
"""
Create fitsfile.
Author : Bhishan Poudel
Date : Sep 4, 2018
Combine two fitsfile keeping their fitsheaders.
let scrollstep = 120
" Settings
let blacklists = [ "*://localhost.com*/*", "*://localhost:*", "*://codepen.io/*", "*://draw.io/*", "*://*slack.com/*", "*://codesandbox.io/*", "*://codewars.com/*", "*://discordapp.com/*", "://gitter.im/*"]
@bhishanpdl
bhishanpdl / svim.vim
Last active September 11, 2018 00:23
" Settings
map "b" scrollToBottom
map "," previousTab
map "." nextTab
let blacklists = [ "https://*.overleaf.com/*", "*://localhost:*", "*://codepen.io/*", "*://draw.io/*", "*://*slack.com/*", "*://codesandbox.io/*", "*://codewars.com/*", "*://discordapp.com/*", "://gitter.im/*"]
@bhishanpdl
bhishanpdl / html preview.js
Last active September 13, 2018 23:14
Render raw html in github etc.. #javascript #html
// Bookmark any webpage and change content with this javascript
javascript:top.location=%22http://htmlpreview.github.com/?%22+document.URL
@bhishanpdl
bhishanpdl / bokeh_interactive_histogram.py
Created October 5, 2018 03:42
Bokeh interactive histogram #bokeh #histogram #interactive
def interactive_histogram(df,col,n_bins,bin_range,title,x_axis_label,x_tooltip):
"""Plot interactive histogram using bokeh.
df: pandas dataframe
col: column of panda dataframe to plot (eg. age of users)
n_bins: number of bins, e.g. 9
bin_range: list with min and max value. e.g. [10,100] age of users.
title: title of plot. e.g. 'Airnb Users Age Distribution'
x_axis_label: x axis label. e.g. 'Age (years)'.
x_tooltip: x axis tooltip string. e.g. 'Age'