This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input = "NAME_DIR"; os.makedirs(input, exist_ok=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3.7.5 | |
# -*- Coding: UTF-8 -*- | |
# Create file with author, title and description | |
import pandas as pd | |
df_all = pd.read_csv('list1.csv') | |
df_desc = pd.read_csv('list2.txt', delimiter='*', header=None) | |
df_desc_ch = pd.read_csv('title_desc.csv') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3.7.5 | |
# -*- Coding: UTF-8 -*- | |
# Read a file with youtube URLs, get info and save into CSV file | |
import requests | |
from bs4 import BeautifulSoup as bs | |
import pandas as pd | |
def get_video_info(url): | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3.7.4 | |
# -*- Coding: UTF-8 -*- | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
df = pd.read_csv('data.csv') | |
plt.title('AOD Pequim - Olimpíadas 2008 (221 a 237)') | |
plt.xlabel('Dia do ano') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# conda install -c conda-forge astral | |
import astral | |
@staticmethod | |
def sun_min(place): | |
""" | |
Return minutes from sunrise to sunset | |
""" | |
l = astral.Location() | |
l.latitude = -15.60083333 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@staticmethod | |
def print_control(place, day): | |
""" | |
Print dates/place control | |
""" | |
#print('%s - %s' %(place, day)) | |
import sys | |
sys.stdout.write('%s - %s\r' %(place, day)) | |
sys.stdout.flush() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
# Loop for all rows | |
for i in range(0,df.shape[0]): | |
# Repace value | |
df.loc[i, 'column_name'] = 5.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
df1 = pd.read_csv('input.csv', delimiter=';', header=None) | |
# Save into fixed columns file | |
import numpy as np | |
with open('output.dat', 'w') as ofile: | |
fmt = '%5d %4d %4d %4d %11.4f %11.4f %11.4f %11.4f %11.4f %11.4f %11.4f %11.4f %11.4f %11.4f %11.4f %11.4f' | |
np.savetxt(ofile, df1.values, fmt=fmt) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Download files from network | |
places=('BRB' 'PTR' 'SMS') | |
years=($(seq 2012 2018)) | |
months=({01..12}) | |
mkdir -p data_amb | |
for place in "${places[@]}"; do | |
echo $place |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def str_to_datetime(s, format_in): | |
""" | |
Convert all elements of a pandas series into datetime format | |
""" | |
import time | |
from datetime import datetime | |
from time import mktime | |
# Convert from day of year from strptime structure | |
strptime_object = s.apply(lambda x: time.strptime(x, format_in)) | |
# Create datetime object |
NewerOlder