Agregamos un par de archivos al repo de Eduardo Graells. Son un CSV con los resultados a nivel nacional (concatenados + añadido número región), y un SQLite con la misma info
This file contains hidden or 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 yfinance as yf | |
| import pandas as pd | |
| import numpy as np | |
| from sklearn.ensemble import GradientBoostingClassifier | |
| import matplotlib.pyplot as plt | |
| # 1. Download Historical Data | |
| print("Downloading data...") | |
| df = yf.download('AAPL', start='2018-01-01', end='2024-01-01') |
This file contains hidden or 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 backtrader as bt | |
| from datetime import datetime | |
| class SmaCross(bt.Strategy): | |
| # Configurable parameters for the strategy | |
| params = dict( | |
| pfast=10, # period for the fast moving average | |
| pslow=30 # period for the slow moving average | |
| ) |
This file contains hidden or 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
| from archicad import ACConnection | |
| import archicad | |
| import math | |
| def generate_narrative_diagram(): | |
| # 1. Connect to Archicad | |
| conn = ACConnection.connect() | |
| assert conn, "Could not connect to Archicad!" | |
| commands = conn.commands | |
| types = conn.types |
This file contains hidden or 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
| from transformers import AutoTokenizer, AutoModelForQuestionAnswering, Trainer, | |
| TrainingArguments, default_data_collator | |
| import datasets | |
| model_name = 'dccuchile/bert-base-spanish-wwm-cased' | |
| tokenizer = AutoTokenizer.from_pretrained(model_name) | |
| model = AutoModelForQuestionAnswering.from_pretrained(model_name) | |
| train_data = datasets.load_dataset('squad_es', 'v1.1.0', split='train[:80%]') |
This file contains hidden or 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 pydicom as dicom | |
| import matplotlib.pylab as plt | |
| import glob | |
| fig=plt.figure(figsize=(20,12));rows=2;cols=2;axes=[] | |
| for a, file in zip(range(rows*cols),glob.glob('*.dcm')): | |
| axes.append( fig.add_subplot(rows, cols, a+1) ) | |
| axes[-1].set_title(file) | |
| axes[-1].axis('off') | |
| plt.imshow(dicom.dcmread(file).pixel_array) |
This file contains hidden or 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 glob | |
| from PyPDF2 import PdfFileMerger | |
| merger = PdfFileMerger() | |
| for fn in glob.glob('*.pdf'): | |
| merger.append(fn) | |
| merger.write('result.pdf') | |
| merger.close() |
This file contains hidden or 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 glob | |
| import cv2 | |
| images = glob.glob('Plot*.png') | |
| print('nImages:', len(images)) | |
| height, width, layers = cv2.imread(images[0]).shape | |
| video = cv2.VideoWriter('video.avi', 0, 1, (width,height)) | |
| for image in images: |
This file contains hidden or 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
| from diagrams import Diagram, Cluster | |
| from diagrams.aws.compute import EC2 | |
| from diagrams.aws.network import ELB | |
| from diagrams.aws.network import Route53 | |
| from diagrams.onprem.database import PostgreSQL # Would typically use RDS from aws.database | |
| from diagrams.onprem.inmemory import Redis # Would typically use ElastiCache from aws.database | |
| with Diagram("Simple Website Diagram", direction='LR') as diag: # It's LR by default, but you have a few options with the orientation | |
| dns = Route53("dns") | |
| load_balancer = ELB("Load Balancer") |
This file contains hidden or 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 wget, fitz, glob | |
| import requests, time | |
| from bs4 import BeautifulSoup | |
| url='http://www.memoriachilena.gob.cl/602/w3-article-100795.html#documentos' | |
| bs = BeautifulSoup(requests.get(url).text, 'lxml') | |
| links = [link['href'] for link in bs.find_all('a') | |
| if '.pdf' in link.get('href','')] | |
| print(len(links)) |
NewerOlder