Skip to content

Instantly share code, notes, and snippets.

View Hammond95's full-sized avatar

Martin Hammond95

View GitHub Profile
@Hammond95
Hammond95 / separator.py
Last active October 31, 2018 17:52 — forked from jlln/separator.py
Efficiently split Pandas Dataframe cells containing lists into multiple rows, duplicating the other column's values.
def explode_from_fields(df, target_columns: list, separator: str):
""" df = dataframe to split,
target_columns = list of the columns containing the values to split,
if the elements returned from the split are not the
same for each columns, the shorter ones are extended
to the longest.
separator = the symbol used to perform the split
returns: A dataframe with each entry for the target column separated,
with each element moved into a new row.
The values in the other columns are duplicated across the newly divided rows."""
@Hammond95
Hammond95 / rrd_exporter.sh
Last active June 23, 2020 10:26 — forked from glamrock/rrd_exporter.sh
Ganglia rrd export / import
#! /bin/bash
# Note: run from /var/lib/ganglia directory, no need for subdir
# Run with: find /var/lib/ganglia/rrds/ -type d -exec sh -c 'cd "{}" ; /var/lib/ganglia/rrd_exporter.sh ;' \;
mkdir -p /tmp/ganglia-export/xml/
RUNDATE="$(date --date='now' +%F-%R)"
BACKUPFILE="/tmp/ganglia-export/rrds-${RUNDATE}.tar"
EXPORTFILE="/tmp/ganglia-export/xml-export-${RUNDATE}.tar"
# backup current rrd files -- tar all and place in /tmp