Skip to content

Instantly share code, notes, and snippets.

javieroot

Block or report user

Report or block javieroot

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
@javieroot
javieroot / guardar-csv.py
Created Aug 13, 2019 — forked from Fhernd/guardar-csv.py
Guarda datos de un DataFrame en formato CSV en Python.
View guardar-csv.py
import pandas as pd
# Definición diccionario:
diccionario = {'pares': [0, 2, 4, 6], 'impares': [1, 3, 5, 7]}
# Creación DataFrame:
df_numeros = pd.DataFrame(diccionario)
# Guarda datos en CSV:
df_numeros.to_csv('numeros.csv', header=False, index=False)
@javieroot
javieroot / mysql-pandas-import.py
Created Aug 8, 2019 — forked from stefanthoss/mysql-pandas-import.py
Import data from a MySQL database table into a Pandas DataFrame using the pymysql package.
View mysql-pandas-import.py
import pandas as pd
import pymysql
from sqlalchemy import create_engine
engine = create_engine('mysql+pymysql://<user>:<password>@<host>[:<port>]/<dbname>')
df = pd.read_sql_query('SELECT * FROM table', engine)
df.head()
@javieroot
javieroot / ordenar-datos.py
Created Aug 8, 2019 — forked from Fhernd/ordenar-datos.py
Ordenar datos de un DataFrame en Python.
View ordenar-datos.py
import pandas as pd
df = pd.DataFrame({'uno': [1, 2, 3], 'dos': [4, 5, 6], 'tres': [7, 8, 9]}, index=['x', 'y', 'z'])
print(df)
print()
# Orden por índice (fila):
print(df.sort_index())
@javieroot
javieroot / SqlAlchemyGet.py
Created May 25, 2019 — forked from Razzo78/SqlAlchemyGet.py
Python, SQL Server - Connect and get data with SqlAlchemy
View SqlAlchemyGet.py
from sqlalchemy import create_engine, MetaData, Table
from sqlalchemy.orm import mapper
from sqlalchemy.sql import select
class MyTable(object):
pass
# Trusted Connection
View connect_and_load.py
import pymssql
import pandas as pd
## instance a python db connection object- same form as psycopg2/python-mysql drivers also
conn = pymssql.connect(server="172.0.0.1", user="howens",password="some_fake_password", port=63642) # You can lookup the port number inside SQL server.
## Hey Look, college data
stmt = "SELECT * FROM AlumniMirror..someTable"
# Excute Query here
df = pd.read_sql(stmt,conn)
@javieroot
javieroot / pandas-dummy-variables.txt
Created May 24, 2019 — forked from sethbunke/pandas-dummy-variables.txt
Simple example of creating dummy variables using Python Pandas
View pandas-dummy-variables.txt
#import pandas and numpy
import pandas as pd
import numpy as np
#create dataframe with some random data
df = pd.DataFrame(np.random.rand(10, 2) * 10, columns=['Price', 'Qty'])
#add a column with random string values that would need to have dummy variables created for them
df['City'] = [np.random.choice(('Chicago', 'Boston', 'New York')) for i in range(df.shape[0])]
@javieroot
javieroot / agregarComandosCmder.txt
Last active Mar 21, 2019
Se agregan rsync, curl y wget a Cmder en bash::mintty
View agregarComandosCmder.txt
# Para abrir cmder desde la carpeta del usuario (el equivalente al home del usuario), editar poniendo cd en el archivo:
# $CMDER_ROOT/config/user_profile.sh
# rsync (esta forma podría funcionar para algún comando más, es cosa de probar que no den error por las dll que pueden
# necesitar)
# Fuente:
# https://discourse.gohugo.io/t/rsync-deploy-and-windows-10/10137/4
1) Descargar como .pkg.tar.xz la última versión del comando que se quiere agregar de http://repo.msys2.org/msys/x86_64/
Por ejemplo, rsync
@javieroot
javieroot / certs.sh
Created Mar 6, 2019 — forked from joakinen/certs.sh
Converting certificates
View certs.sh
#!/bin/sh
# ____ _____ ____ _____ ___ _____ ___ ____ _ _____ _____ ____
# / ___| ____| _ \_ _|_ _| ___|_ _/ ___| / \|_ _| ____/ ___|
# | | | _| | |_) || | | || |_ | | | / _ \ | | | _| \___ \
# | |___| |___| _ < | | | || _| | | |___ / ___ \| | | |___ ___) |
# \____|_____|_| \_\|_| |___|_| |___\____/_/ \_\_| |_____|____/
# ____ _______ __
# | _ \| ___\ \/ /
@javieroot
javieroot / excel_read.py
Created Aug 22, 2018 — forked from dlouapre/excel_read.py
Read excel file in Python
View excel_read.py
# -*- coding: utf-8 -*-
import xlrd
# Open the file
wb = xlrd.open_workbook('test.xlsx')
# Get the list of the sheets name
sheet_list = wb.sheet_names()
print sheet_list
@javieroot
javieroot / RPostgreSQL.R
Created Aug 12, 2018
Conexión a base de datos de PostgreSQL desde R
View RPostgreSQL.R
# Una vez teniendo lista la instalación de PostgreSQL y R:
# En el terminal:
pacman -S postgresql-libs
# Dentro de R instalar el paquete RPostgreSQL
install.packages("RPostgreSQL")
# Una vez realizado lo anterior se procede a realizar la conexión con:
You can’t perform that action at this time.