Skip to content

Instantly share code, notes, and snippets.

View afr-dt's full-sized avatar
:octocat:

Alejandro Flores afr-dt

:octocat:
  • Personal
  • Mexico City
View GitHub Profile
@afr-dt
afr-dt / pandas_dataframe_difference.py
Created June 8, 2020 15:57 — forked from toddbirchard/pandas_dataframe_difference.py
Helper function to compare two DataFrames and find rows which are unique or shared.
def dataframe_difference(df1, df2, which=None):
"""Find rows which are different."""
comparison_df = df1.merge(df2,
indicator=True,
how='outer')
if which is None:
diff_df = comparison_df[comparison_df['_merge'] != 'both']
else:
diff_df = comparison_df[comparison_df['_merge'] == which]
diff_df.to_csv('data/diff.csv')
@afr-dt
afr-dt / README-Template.md
Created March 30, 2020 20:33 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@afr-dt
afr-dt / iterm2-solarized.md
Created October 27, 2019 07:06 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

@afr-dt
afr-dt / init.vim
Last active November 1, 2019 03:22
My Neovim setup 👨🏽‍💻😃
call plug#begin()
" syntax check
Plug 'w0rp/ale'
" Autocomplete
Plug 'ncm2/ncm2'
Plug 'roxma/nvim-yarp'
Plug 'ncm2/ncm2-path'
Plug 'ncm2/ncm2-jedi'
" Formater

Oh my zsh.

Install with curl

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

Enabling Plugins (zsh-autosuggestions & zsh-syntax-highlighting)

  • Download zsh-autosuggestions by
@afr-dt
afr-dt / strip_srt.py
Created October 31, 2018 22:56
Strip punctuation from a string in Python
In [1]: import re
In [2]: tacos = "Tacos al pastor, suadero, bistec y de canasta."
In [3]: tacos = re.sub(r'[^a-zA-Z0-9\s]', '', tacos)
In [4]: tacos
Out[4]: 'Tacos al pastor suadero bistec y de canasta'
@afr-dt
afr-dt / description.md
Created September 28, 2018 18:57 — forked from mangecoeur/description.md
Pandas PostgresSQL support for loading to DB using fast COPY FROM method

This small subclass of the Pandas sqlalchemy-based SQL support for reading/storing tables uses the Postgres-specific "COPY FROM" method to insert large amounts of data to the database. It is much faster that using INSERT. To acheive this, the table is created in the normal way using sqlalchemy but no data is inserted. Instead the data is saved to a temporary CSV file (using Pandas' mature CSV support) then read back to Postgres using Psychopg2 support for COPY FROM STDIN.

@afr-dt
afr-dt / import_csv_to_mongo
Created September 11, 2018 06:29 — forked from mprajwala/import_csv_to_mongo
Store CSV data into mongodb using python pandas
#!/usr/bin/env python
import sys
import pandas as pd
import pymongo
import json
def import_content(filepath):
mng_client = pymongo.MongoClient('localhost', 27017)
@afr-dt
afr-dt / pokemon.json
Created August 13, 2018 01:34 — forked from shri/pokemon.json
JSON of pokemon to go with my pokemonMoves.json file
{
"1":{
"name":"Bulbasaur",
"attack":49,
"defense":49,
"evolveLevel":16,
"evolveTo":"2",
"type":"grass",
"moves":[
"tackle",
@afr-dt
afr-dt / settings.json
Last active March 22, 2019 21:58
My settings for vscode
{
"workbench.iconTheme": "vscode-icons",
"workbench.editor.enablePreview": true,
"html.autoClosingTags": true,
"html.format.preserveNewLines": true,
"editor.tabSize": 2,
"editor.snippetSuggestions": "top",
"workbench.colorCustomizations": {
"editor.fontLigatures": true,
"editor.selectionHighlight": true,