Skip to content

Instantly share code, notes, and snippets.

View data4sci's full-sized avatar

Robert Samarek data4sci

  • VSB - Technical University of Ostrava
  • Ostrava, Czech Republic
View GitHub Profile
@data4sci
data4sci / .sh
Created May 25, 2021 08:52
batch resize JPG
for file in *.jpg; do convert $file -resize 1800x res-$file; done
# 1800x šířka 1800 px
# x1000 výška 1000 px
@data4sci
data4sci / .py
Created May 25, 2021 08:53
inline DataFrame definition #pandas #python
df = pd.DataFrame({'col1': [1, 2], 'col2': [3, 4]})
#-----------------------
# empty df
df = pd.DataFrame({'col1': [],
'col2': [],
'col3': []})
@data4sci
data4sci / .py
Created May 25, 2021 09:13
column names normalization #pandas #python
DF = pd.read_csv('data/nyc-jobs.csv')
new_columns = [column.replace(' ', '_').lower() for column in DF]
DF.columns = new_columns
@data4sci
data4sci / .py
Created May 25, 2021 09:14
#python #pandas DF iterrows
for _, row in df.iterrows():
print(row["name"])
@data4sci
data4sci / drop_all.sql
Created May 25, 2021 09:15
DROP all Tables #SQL
DROP SCHEMA public CASCADE; CREATE SCHEMA public; GRANT USAGE ON SCHEMA public to PUBLIC; GRANT CREATE ON SCHEMA public to PUBLIC; COMMENT ON SCHEMA public IS 'standard public schema';
@data4sci
data4sci / .py
Created May 25, 2021 09:18
#python print() modifiers
print(item, sep=' ', end='', flush=True)
@data4sci
data4sci / .py
Created May 25, 2021 09:19
#python seznam proměnných a velikost v paměti
import sys
# These are the usual ipython objects, including this one you are creating
ipython_vars = ['In', 'Out', 'exit', 'quit', 'get_ipython', 'ipython_vars']
# Get a sorted list of the objects and their sizes
sorted([(x, sys.getsizeof(globals().get(x))) for x in dir() if not x.startswith('_') and x not in sys.modules and x not in ipython_vars], key=lambda x: x[1], reverse=True)
@data4sci
data4sci / .sh
Created May 25, 2021 09:21
resize swap file
# změna velikosti SWAP souboru na 8GB
# https://forums.linuxmint.com/viewtopic.php?t=284301
# https://linuxhint.com/change_swap_size_ubuntu/
swapon # kontrola velikosti na začátku
sudo swapoff -a
sudo dd if=/dev/zero of=/swapfile bs=1M count=8192
sudo chmod 0600 /swapfile
sudo mkswap /swapfile
@data4sci
data4sci / .sh
Created May 25, 2021 09:22
STOP Jupyter server at specified port
$ jupyter notebook stop 8889
@data4sci
data4sci / gist:5a39d04f6fb390525cd4a5e4b16e8460
Created May 25, 2021 09:25
Změna hodnot v df metodou map() #python #pandas
df['sex_letter] = df.sex.map({'Male': 'M', 'Female': 'F'}).fillna('O')