Skip to content

Instantly share code, notes, and snippets.

@rohitsuratekar
rohitsuratekar / cluster_df.py
Last active July 16, 2021 10:14
Clusters pandas dataframe
# Just pass any numerical dataframe into following fuction and it will cluster the columns and rows.
# Adjust the parameters for your clustering according to your taste
def cluster_df(df):
from scipy.cluster.hierarchy import dendrogram
from scipy.spatial import distance
d = distance.pdist(df)
dn = hierarchy.dendrogram(hierarchy.linkage(d),no_plot=True)['leaves']
rearr_map = {i:x for i,x in enumerate(df.columns)}
df = df[[rearr_map[x] for x in dn]]
@rohitsuratekar
rohitsuratekar / ipl.py
Last active December 11, 2020 12:17
Every IPL Match Played!
# Visualizing IPL Matches
# Author: Rohit Suratekar
#
# Data: https://www.kaggle.com/patrickb1912/ipl-complete-dataset-20082020
import csv
from collections import Counter
import numpy as np
from chord import Chord
@rohitsuratekar
rohitsuratekar / nobel.py
Created December 6, 2020 11:27
Nobel Laureate visualization
# Visualizing Nobel Laureate Migration
# Author: Rohit Suratekar
#
# Data: https://www.kaggle.com/nobelfoundation/nobel-laureates
import csv
from collections import Counter
import numpy as np
import plotly.graph_objects as go
@rohitsuratekar
rohitsuratekar / friends.py
Created December 2, 2020 18:47
Friends characters
import matplotlib.pyplot as plt
from SecretColors import Palette
import matplotlib
matplotlib.rc("font", family="IBM Plex Sans")
data = [
("Rachel", 9, "Barry, Paolo, Ross, Russ, Joshua, Paul,\nTag Jones, "
"Gavin, Joey"),
("Monica", 11,
"Paul, Alan, Fun Bobby, Young, Jean-Claude, Richard, Julio, Pete,"
@rohitsuratekar
rohitsuratekar / books_title.py
Created November 26, 2020 18:12
Code to generate the book title statistics
# Author: Rohit Suratekar
#
# Data Source: https://www.kaggle.com/jealousleopard/goodreadsbooks
import csv
import os
from collections import Counter, defaultdict
import matplotlib
import matplotlib.pyplot as plt
@rohitsuratekar
rohitsuratekar / sars-pi.py
Created November 2, 2020 23:01
SARS-Cov2-Pi visualization
# Rohit Suratekar (c) 2020
# SARS-COVID-PI visualization
#
# Data Sources:
# Genome Source : https://www.ncbi.nlm.nih.gov/nuccore/NC_045512.2
# Pi Digits : https://www.piday.org/million/
import matplotlib.pylab as plt
from SecretColors import Palette
@rohitsuratekar
rohitsuratekar / india_pm.py
Created August 26, 2020 08:51
Visualize stats about Indian PMs from 1947-2020
# Author: Rohit Suratekar
#
# I was learning 'suqrify' library and hence this is very hasty code. I have adjusted everything manually.
# DO NOT use this in any production/library. Make more robust code.
#
# Data from Wikipedia :https://en.wikipedia.org/wiki/List_of_prime_ministers_of_India
# Accessed on 26 August 2020
from collections import Counter
@rohitsuratekar
rohitsuratekar / uniqe_fragments.py
Created April 29, 2020 14:01
Searches through given peptide sequences to generate unique fragments and their counts.
# Copyright (c) 2020
# Author: Rohit Suratekar
#
# This program finds unique peptides and their frequency in given peptide
# fragment data.
#
# IMPORTANT NOTE:
# This assumes there are NO Gaps in your peptide sequence
# Every peptide sequence has to be sequential without any gap.
# Your INPUT peptide data.
@rohitsuratekar
rohitsuratekar / kaybase.md
Created November 13, 2019 08:56
Keybase verification

Keybase proof

I hereby claim:

  • I am rohitsuratekar on github.
  • I am rohitsuratekar (https://keybase.io/rohitsuratekar) on keybase.
  • I have a public key ASDps3iCA9fkiB7qCmyFS-dhFYghaICfEk2sywoR6ILK7Qo

To claim this, I am signing this object:

@rohitsuratekar
rohitsuratekar / facebook_filters.js
Created July 14, 2019 10:14
uBlock Origin filters for facebook sponsor ads
! Collected from random internet websites
facebook.com##div[id^=hyperfeed_story_id_]:has(a[role^=button]:has(> span:has-text(/S/i):has-text(p):has-text(o):has-text(n):has-text(r):has-text(e):has-text(d):not(:has-text(m)):not(:has-text(M)):not(:has-text(h)):not(:has-text(:)):not(:has-text(J))))
facebook.com##:xpath(//div[starts-with(@id, 'pagelet') and (.//a[.='Sponsored'])] )
facebook.com###pagelet_ego_pane
facebook.com###pagelet_video_home_watch_list_rhc
facebook.com##div[id=hyperfeedstory_id]:has(a[role=button]:has(> b class:has-text(/S/i):has-text(p):has-text(o):has-text(n):has-text(r):has-text(e):has-text(d):not(:has-text(m)):not(:has-text(M)):not(:has-text(h)):not(:has-text(:)):not(:has-text(J))))
facebook.com##[id^="hyperfeed_story_"]:if(.userContentWrapper
div[id^="feed_subtitle_"]