Skip to content

Instantly share code, notes, and snippets.

View trevismd's full-sized avatar

Florian Charlier trevismd

  • Belgium
View GitHub Profile
@trevismd
trevismd / Abbreviate Journal Names in Bibtex Database.py
Last active January 28, 2021 07:51 — forked from FilipDominec/Abbreviate Journal Names in Bibtex Database.py
Using the translation table from the Jabref program, finds and replaces all scientific journal names to their standardized abbreviated form. First argument is the file to be processed; outputs safely to 'abbreviated.bib'
#!/usr/bin/env python
#-*- coding: utf-8 -*-
# Supporting Python 3 and JabRef csv file
import os
import re
import sys
try:
bibtexdb = open(sys.argv[1]).read()
@trevismd
trevismd / to_statannotations.py
Last active October 16, 2022 15:46
Create a `statannotations` v0.5+ `StatTest` with a permutations-stats test
import matplotlib.pyplot as plt
import permutations_stats.permutations as pms
import seaborn as sns
from statannotations.statannotations import Annotator
from statannotations.stats.StatTest import StatTest
stat_test = StatTest(func=pms.permutation_test,
test="brunner_munzel",
test_long_name="Brunner Munzel exact test",
@trevismd
trevismd / Statannotations-Tutorial-1-1.py
Last active July 5, 2021 07:59
Statannotations-Tutorial-1 Imports
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
# A few helper functions:
from utils import *
# To illustrate examples
import numpy as np
from scipy.stats import mannwhitneyu, normaltest
@trevismd
trevismd / Statannotations-Tutorial-1-2.py
Created July 4, 2021 17:59
Load kickstarter dataset
dataset = pd.read_csv('kickstarter_projects.csv')
dataset.head()
@trevismd
trevismd / Statannotations-Tutorial-1-3.py
Last active July 5, 2021 08:17
Unique categories in dataset
list(dataset.Category.unique())
>>> ['Fashion', 'Film & Video', 'Art', 'Technology', 'Journalism', 'Publishing',
'Theater', 'Music', 'Photography', 'Games', 'Design', 'Food', 'Crafts',
'Comics', 'Dance']
@trevismd
trevismd / Statannotations-Tutorial-1-4.py
Last active July 7, 2021 19:23
Tech projects and subcategories
tech = dataset.loc[(dataset.Category=='Technology'), :]
print_n_projects(tech, 'Technology')
print_projects_by(tech, 'ID', 'count')
@trevismd
trevismd / Statannotations-Tutorial-1-5.py
Created July 4, 2021 18:11
Robots Flight Sound projects
rfs = tech.loc[(tech.Subcategory.isin(("Robots", "Flight", "Sound"))), :]
print_n_projects(rfs, "rfs")
>>> There are 1667 projects in rfs.
@trevismd
trevismd / Statannotations-Tutorial-1-6.py
Last active August 3, 2021 07:06
Color and order - Subcategories
subcat_palette = sns.dark_palette("#8BF", reverse=True, n_colors=5)
subcat_order = ['Robots', 'Flight', 'Sound']
with sns.plotting_context("notebook", font_scale=1.4):
# Create new plot, setting a logarithmic scale for y
ax = get_log_ax()
# Plot with seaborn
sns.boxplot(ax=ax, data=rfs, x='Subcategory', y='Goal', palette=subcat_palette[1:])
# Label (adds axes labels and title), and show
label_plot_for_subcats(ax)
plt.savefig("plot1.png")
# [code common to all plots]
# Plot with seaborn
sns.boxplot(ax=ax, data=rfs, x='State', y='Goal', order=states_order,
palette=states_palette)
# [code common to all plots]