Skip to content

Instantly share code, notes, and snippets.

@ljak
ljak / pandas_trick.txt
Created July 21, 2020 23:35
Pandas read CSV and prefix every row value with column name
df = pd.read_csv(WORKING_FOLDER + FILE, index_col=0)
# columns names = list(df.columns.values)
def prefix_every_row_with_column_name(column):
return column.name + " : " + column.astype(str)
df = df.apply(lambda column: prefix_every_row_with_column_name(column), axis=0) # axis=0 are the columns
@ljak
ljak / unknown_bash_commands.sh
Created August 5, 2019 14:47
Some "unknown" bash commands that are really nice.
# 1. redo last command but as root
sudo !!
# 2. open an editor to run a command
ctrl+x+e
# 3. create a super fast ram disk
mkdir -p /mnt/ram
mount -t tmpfs tmpfs /mnt/ram -o size=8192M