Skip to content

Instantly share code, notes, and snippets.

View idcesares's full-sized avatar
:octocat:
Keep on hacking!

Isaac D'Césares idcesares

:octocat:
Keep on hacking!
View GitHub Profile
@idcesares
idcesares / cidades_ibge.py
Created July 5, 2021 15:15
Exportar cidades brasileiras da api do IBGE para csv
import pandas as pd
import requests
response = requests.get('https://servicodados.ibge.gov.br/api/v1/localidades/municipios')
df = pd.read_json(response.text)
cidades = df['nome']
cidades.to_csv("cidades.csv", index=False)
@idcesares
idcesares / tensorflow_simple_neural_network.py
Created May 29, 2021 15:06
Simple Neural Network using Tensorflow
# Imports
import tensorflow as tf
import numpy as np
from tensorflow import keras
# Define and compile the Neural Network (NN)
model = tf.keras.Sequential([keras.layers.Dense(units=1, input_shape=[1])]) # Only 1 neuron
# Compile the NN
model.compile(optimizer='sgd', loss='mean_squared_error')
@idcesares
idcesares / day_of_year.py
Created May 5, 2021 22:31
Shows how many days have passed since the beginning of the year
from datetime import datetime
day_of_year = datetime.now().timetuple().tm_yday
print(f"What's the Current Day Number? {day_of_year} days have passed since the beginning of the year.")
@idcesares
idcesares / sentiment_analysis_textblob.py
Created April 26, 2021 22:51
Simple Sentiment Analysis using TextBlob Python Library. Only available in english.
from textblob import TextBlob
def sentiment(text):
base_text = TextBlob(text)
sentiment_score = base_text.sentiment.polarity
if sentiment_score < 0:
return 'Negative'
elif sentiment_score == 0:
return 'Neutral'
return 'Positive'
@idcesares
idcesares / consume_public_api.py
Last active April 23, 2021 19:51
How to easily consume an Public API in Python and convert the result into a Pandas Dataframe
# Basic libraries
import requests
import pandas as pd
import json
# Define API URL
url = 'API_link'
# Consume API
response = requests.get(url).json()
@idcesares
idcesares / join_csv_powershell.ps1
Last active April 23, 2021 19:53
Combine multiple CSV files into one using Powershell
Get-ChildItem -Filter *.csv | Select-Object -ExpandProperty FullName | Import-Csv | Export-Csv .\combinedcsvs.csv -NoTypeInformation -Encoding UTF8 -Append
@idcesares
idcesares / tts.py
Created April 26, 2020 17:40
Usando a biblioteca pyttsx3 para text-to-speech no Python
# Instalar o pyttsx3 com o comando abaixo:
# pip install pyttsx3
import pyttsx3
# Iniciando a biblioteca na variável engine
engine = pyttsx3.init()
# Função pronta para uso
def speak(speech):