Skip to content

Instantly share code, notes, and snippets.

View KPLauritzen's full-sized avatar

Kasper Primdal Lauritzen KPLauritzen

View GitHub Profile
@KPLauritzen
KPLauritzen / useful_pandas_snippets.py
Created January 10, 2017 12:34 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
# List unique values in a DataFrame column
pd.unique(df.column_name.ravel())
# Convert Series datatype to numeric, getting rid of any non-numeric values
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True)
# Grab DataFrame rows where column has certain values
valuelist = ['value1', 'value2', 'value3']
df = df[df.column.isin(valuelist)]
@KPLauritzen
KPLauritzen / lol.py
Created February 14, 2017 11:21
Kill random process with python
from subprocess import call
import random
while True:
try:
call(["kill", "-9", random.randint(0, 9999)]
except:
print("ayy lmao")
sleep(5)
@KPLauritzen
KPLauritzen / test_asap_crash.py
Created April 7, 2017 10:19
Succeeds with `--size 7`, fails with `--size 8`
from __future__ import print_function
import numpy as np
import argparse
from ase.units import kB, fs
from ase.build import fcc111
from asap3 import EMT
from asap3.md.langevin import Langevin
@KPLauritzen
KPLauritzen / azure-pipeline.yaml
Created April 20, 2021 14:31
Pipeline for using micromamba in a azure devops pipeline
jobs:
- job:
pool:
vmImage: 'vs2017-win2016'
variables:
- name: MAMBA_ROOT_PREFIX
value: $(Pipeline.Workspace)\micromambaenv
steps:
- powershell: |
Invoke-Webrequest -URI https://micro.mamba.pm/api/micromamba/win-64/latest -OutFile micromamba.tar.bz2