Skip to content

Instantly share code, notes, and snippets.

View lyashevska's full-sized avatar

Olga Lyashevska lyashevska

View GitHub Profile
# 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)]
@lyashevska
lyashevska / join_dataframes_using_parts_of_datetime_index.py
Last active June 21, 2017 09:33
join 2 dataframes using year and month parts of date time index
import pandas as pd
d = {'dat': ['2016-01-01', '2016-01-02', '2016-01-03', '2017-01-01', '2017-01-02', '2017-01-03'],'x': [1, 2, 3, 4, 5, 6]}
df1 = pd.DataFrame(d)
df1.set_index(['dat'], inplace=True)
df1.index = pd.to_datetime(df1.index)
d = {'dat': ['2016-01-01', '2017-01-01'],'y': [10, 11]}
df2 = pd.DataFrame(d)
df2.set_index(['dat'], inplace=True)
@lyashevska
lyashevska / eps2png.sh
Created November 9, 2017 11:39
batch conversion of eps to png in bash
for f in `ls *.eps`; do
convert -density 100 $f -flatten ${f%.*}.png;
done
@lyashevska
lyashevska / gist:ba4cbad68f4b5238c33885c958654747
Created July 23, 2018 12:14
vagrant: destination host unreachable
ping -c 3 10.9.8.7
PING 10.9.8.7 (10.9.8.7) 56(84) bytes of data.
From 10.9.8.1 icmp_seq=1 Destination Host Unreachable
From 10.9.8.1 icmp_seq=2 Destination Host Unreachable
From 10.9.8.1 icmp_seq=3 Destination Host Unreachable
--- 10.9.8.7 ping statistics ---
3 packets transmitted, 0 received, +3 errors, 100% packet loss, time 2048ms
pipe 3
@lyashevska
lyashevska / add-local-user.sh
Created August 24, 2018 11:32
add local user
#! /bin/bash
# this script will create new user accounts
# enforce execution with a root priviledges,
# return status 1 if not root
if [[ "${UID}" -eq 0 ]]
then
# enter the username (login),
@lyashevska
lyashevska / add-new-local-user.sh
Created September 25, 2018 15:24
add-new-local-user
#!/bin/bash
# Make sure the script is being executed with superuser privileges.
if [[ "${EUID}" -ne 0 ]]; then
echo 'The script requires root priveledges'
exit 1
fi
# supply at least one argument otherwise return an exit status of 1
if [[ "${#}" -lt 1 ]]
@lyashevska
lyashevska / README-Template.md
Created November 11, 2019 12:35 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

Bootstrap: docker
From: openjdk:17
%arguments
NETLOGO_VERSION=6.3.0
%setup
# Download Netlogo on host if not already present
wget -nc https://ccl.northwestern.edu/netlogo/{{NETLOGO_VERSION}}/NetLogo-{{NETLOGO_VERSION}}-64.tgz
"""
Purpose: this script creates GitHub gists for all files in a directory.
Adapted from
https://jels-boulangier.medium.com/automatically-create-github-gists-for-your-medium-articles-ba689775b032
Usage: python create_gists.py <directory>
"""
import subprocess
import sys
from pathlib import Path
#!/bin/bash
sudo apptainer build netlogo-headless.sif netlogo-headless.def