Skip to content

Instantly share code, notes, and snippets.

Vinicius Roggério da Rocha viniroger

Block or report user

Report or block viniroger

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
viniroger /
Created Aug 8, 2019
Ideas for extreme value filter
def filtro(self, df, uid):
"""Filter forecasted values
Check acceptable values, replacing when it isn't
import statistics
if uid == 215:
lower_limit = 10
upper_limit = 3000
elif uid == 216:
lower_limit = 10
viniroger /
Created Jul 22, 2019
Convert object to datetime64 ns and print columns types
y_true['ds'] = pd.to_datetime(y_true['ds'])
viniroger /
Created Jul 10, 2019
Select files by pattern and zip into new file
ls *VS00* *VSS.* | zip -@ saida/
viniroger /
Last active Jul 10, 2019
Shell script to send e-mail with attachments and body to mails list
# Escrever corpo do e-mail
echo "Seguem anexos" >> $arq_email
printf "\n" >> $arq_email
# Arquivo de texto no corpo de e-mail
cat $arq_descr >> $arq_email
# Criar lista de e-mails a partir de arquivo
readarray -t lista_emails < <(cat $DIR/helpers/destinatarios_teste.txt | grep $grupo | awk -F',' '{print $1}')
viniroger / trycatch.R
Created Apr 22, 2019
Try catch read CSV file with error function and warning print
View trycatch.R
diretorio = '/home/user/model'
uid = 1
filename = sprintf('%s/saida/saida_%s/prevaz_%s.csv', diretorio, 'semanal', uid)
values = tryCatch(read.csv(filename, = TRUE),
error = function(e) NA, warning = function(w) print('Without semanal file'))
viniroger /
Created Mar 26, 2019
Generate random password
openssl rand -base64 8
viniroger /
Created Mar 21, 2019
Fill a column from a pandas dataframe with random values
import random
df['column_name'] = df['column_name'].apply(lambda v: random.random() * 100)
viniroger /
Created Feb 28, 2019
Pretty-print an entire Pandas Series / DataFrame
def print_all_df(self, df):
with pd.option_context('display.max_rows', None, 'display.max_columns', None):
viniroger /
Created Feb 28, 2019
Execute bash script using python
from subprocess import check_output
# List files using pattern and get most recent
bashCommand = ("ls -1t %s/saida/arquivos_clientes/cn*.txt | head -1" %path)
# Define file name as last string, striping by '/'
filename = str(check_output(bashCommand, shell=True).strip(), 'utf-8')
remoteFileName = filename.split('/')[-1]
viniroger /
Created Feb 21, 2019
Example of lambda function use with conditional statment - Python
# Example of Conditional statements using lambda funtion
dates = ['2019-02-20','2019-02-21','2019-02-22']
td = '2019-02-21'
i = 0
# Conditional statement
if dates[i] < td:
# Conditional statement with lambda
You can’t perform that action at this time.