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
viniroger / filtro.py
Created Aug 8, 2019
Ideas for extreme value filter
View filtro.py
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
viniroger / convert.py
Created Jul 22, 2019
Convert object to datetime64 ns and print columns types
View convert.py
y_true['ds'] = pd.to_datetime(y_true['ds'])
print(y_true.dtypes)
@viniroger
viniroger / zip_files.sh
Created Jul 10, 2019
Select files by pattern and zip into new file
View zip_files.sh
ls *VS00* *VSS.* | zip -@ saida/arquivo.zip
@viniroger
viniroger / send_mail.sh
Last active Jul 10, 2019
Shell script to send e-mail with attachments and body to mails list
View send_mail.sh
envio_email(){
# 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
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,as.is = TRUE),
error = function(e) NA, warning = function(w) print('Without semanal file'))
@viniroger
viniroger / randompass.sh
Created Mar 26, 2019
Generate random password
View randompass.sh
openssl rand -base64 8
@viniroger
viniroger / fill_random.py
Created Mar 21, 2019
Fill a column from a pandas dataframe with random values
View fill_random.py
import random
random.seed(42)
df['column_name'] = df['column_name'].apply(lambda v: random.random() * 100)
@viniroger
viniroger / print_all_df.py
Created Feb 28, 2019
Pretty-print an entire Pandas Series / DataFrame
View print_all_df.py
def print_all_df(self, df):
with pd.option_context('display.max_rows', None, 'display.max_columns', None):
print(df)
@viniroger
viniroger / bash_execution.py
Created Feb 28, 2019
Execute bash script using python
View bash_execution.py
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
viniroger / lambda_ex.py
Created Feb 21, 2019
Example of lambda function use with conditional statment - Python
View lambda_ex.py
# 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:
print('obs')
else:
print('prev')
# Conditional statement with lambda
You can’t perform that action at this time.