Skip to content

Instantly share code, notes, and snippets.

Avatar

Cristhian Boujon CristhianBoujon

View GitHub Profile
@CristhianBoujon
CristhianBoujon / get_top_n_words.py
Last active May 20, 2021
List the words in a vocabulary according to occurrence in a text corpus , Scikit-Learn
View get_top_n_words.py
def get_top_n_words(corpus, n=None):
"""
List the top n words in a vocabulary according to occurrence in a text corpus.
get_top_n_words(["I love Python", "Python is a language programming", "Hello world", "I love the world"]) ->
[('python', 2),
('world', 2),
('love', 2),
('hello', 1),
('is', 1),
View submission.csv
posting_id matches
test_2255846744 test_2255846744 test_2255846745
test_2255846745 test_2255846745 test_2255846744
test_3588702337 test_3588702337
test_4015706929 test_4015706929
View simulacion.py
import tkinter as tk
import time
class Particula:
def __init__(self, x, y, radio, color='blue'):
self.circulo = canvas.create_oval(
x - radio, y - radio, x + radio, y + radio, fill=color
)
@CristhianBoujon
CristhianBoujon / python_pip.md
Last active Oct 5, 2018
instalar python & pip en mac
View python_pip.md

Instalar brewhome

brewhome es un gestor de paquetes

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Instalar pyenv

Pueden instalar directamente python haciendo brew install python pero les instala la última versión. Puede que esto no sea lo que queremos y brew no nos da una manera fácil de instalar versiones anteriores, así que decidí utilizar pyenv brew install pyenv

pyenv install <python verion that you want>

View ts_2.py
import pandas as pd
import matplotlib.pyplot as plt
ads_report = pd.read_csv('ads_report_by_categories.csv', parse_dates=["date"], index_col='date')
ads_report.plot()
plt.show()
View ts.py
import pandas as pd
import matplotlib.pyplot as plt
ads_report = pd.read_csv('ads_report.csv', parse_dates=["date"], index_col='date')
ads_report.plot()
plt.show()
View cars_for_sell.py
cars_for_sell = [line.replace("\n", "") for line in open("cars_for_sell.txt")]
common_words = get_top_n_words(cars_for_sell, 20)
for word, freq in common_words:
print(word, freq)
View cars_for_sell.txt
2017 GMC Sierra 1500
2010 Toyota Sienna
2016 Volkswagen Beetle
2011 Dodge Ram
2003 Land-Rover Range Rover
2004 Nissan Frontier
2007 Saturn Aura
2001 Ford Ranger
2012 Mercedes-Benz E
2003 Ford F-250
@CristhianBoujon
CristhianBoujon / gist:ffbb5c2ac7f861c8a65244398b11ff02
Created May 8, 2017 — forked from matoakley/gist:1092571
MySQL to convert a string into a slug
View gist:ffbb5c2ac7f861c8a65244398b11ff02
LOWER(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(TRIM('My String'), ':', ''), ')', ''), '(', ''), ',', ''), '\\', ''), '\/', ''), '\"', ''), '?', ''), '\'', ''), '&', ''), '!', ''), '.', ''), ' ', '-'), '--', '-'), '--', '-')) AS `post_name`
@CristhianBoujon
CristhianBoujon / dollar_rate.r
Last active Jul 28, 2017
Plot Time serie from CSV in four lines with R
View dollar_rate.r
library(xts)
dollar_rate <- read.csv("dollar_rate.csv", colClasses = c("Date", NA))
dollar_rate_ts <- xts(dollar_rate$VALUE, order.by = dollar_rate$DATE)
plot(dollar_rate_ts, main = "Dollar Rate", xlab = "Date", ylab = "$")