Multiple Ways to Get the First Row for Each Group in Pandas

Use case Sometimes you just want to capture the first (or last) event of something. Let’s say, you have a list of clients and want to capture their first purchase. This is useful if you want a list of new paying customers. Dataset We’re thinking about customers here, so let’s get the Online Retail Dataset from the UCI Machine Learning Repository. We can download this dataset directly using Pandas. >>> import pandas as pd >>> customers = pd....

<span title='2020-12-03 19:12:26 -0600 -0600'>December 3, 2020</span>&nbsp;·&nbsp;7 min&nbsp;·&nbsp;Franccesco Orozco

Monitoring Nginx with @sherlog/cli

Logs play a very important role throughout the entire life cycle of an application development as well as troubleshooting and replicating bugs on production that could lead to service interruption and harm our user’s experience. A few months ago, I went on a journey for finding a tool that will allow me to improve logs visibility and to take action as quickly as possible, and of course with a minimum amount of effort and server requirements....

<span title='2020-10-07 16:20:23 +0000 UTC'>October 7, 2020</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;Bruce Lampson
Image by @ingoschulz

Python Logging Basics: Why is it important and how to use it?

If you find yourself having troubles debugging your code, or wondering what went wrong, then you should start logging events in your python code. Using the logging library you can basically record what actions is your code doing, i.e making a web request, reading a file, monitoring something, etc. It can help you to narrow down your faulty code for debugging. Moreover, logging is not only helpful for debugging, but it is also helpful for collaboration, and many platforms use the logging module in your code so you navigate between events easily....

<span title='2020-06-27 09:45:41 +0000 UTC'>June 27, 2020</span>&nbsp;·&nbsp;5 min&nbsp;·&nbsp;Franccesco Orozco

Develop and Publish Your Python Packages with Poetry

I’ve been trying to publish my packages to PyPi so people can access my software more easily. But I have to be honest, Python’s publishing system is not the best out there and it has to improve quite a lot. Wandering around I stumbled upon Poetry, which is a python packager and dependency manager created by Sébastien Eustace for people that doesn’t want to lose their head managing a Python project....

<span title='2019-06-16 11:20:44 +0000 UTC'>June 16, 2019</span>&nbsp;·&nbsp;6 min&nbsp;·&nbsp;Franccesco Orozco

How to Easily Use a Progress Bar in Python

We’ve all been there, your code is performing a job and it’s going to take a while. I’m an impatient guy, so it would be nice to have an ETA or a progress bar to show us. Fortunately, there are libraries out there than can help us to achieve this! There’s two ways in which we can integrate a progress bar into our loops, via a Context Manager or just wrapping up an iterable object into a method....

<span title='2019-06-15 20:40:39 +0000 UTC'>June 15, 2019</span>&nbsp;·&nbsp;6 min&nbsp;·&nbsp;Franccesco Orozco

Create a Project Page for Your Repos Easily With Jekyll and GitHub Pages

I’m going to show you how to create a project page using the ever popular Jekyll and GitHub Pages so your projects can have a face, and of course, to show it of to your friends out there. So, without further ado, we should get to the point already, shall we? Building our site with Jekyll Let’s say that you have a project called chuck-says that acts like a fortune cookie + cowsay whenever you call it in the command line....

<span title='2019-06-08 20:24:14 +0000 UTC'>June 8, 2019</span>&nbsp;·&nbsp;7 min&nbsp;·&nbsp;Franccesco Orozco

How to Create a Ruby Gem With Bundler

I’ve been writing and focusing on Python lately and I’ve been wanting to make more content about Ruby. Ruby was my very first language and the one that got me into this programming world. For this entry I’m going to write how to create, test and publish our gem to RubyGems.org to make it available for everyone, and in future entries we’re going to see how to setup a CI/CD for automatic testing and deployment, Behavior Driven Testing with Cucumber/Aruba and Code Coverage with SimpleCov....

<span title='2019-03-06 12:44:08 +0000 UTC'>March 6, 2019</span>&nbsp;·&nbsp;36 min&nbsp;·&nbsp;Franccesco Orozco

Generate and Verify Your Commits With GPG in GitHub

Why should you do it? “Using GPG, you can sign and verify tags and commits. With GPG keys, tags or commits that you’ve authored on GitHub are verified and other people can trust that the changes you’ve made really were made by you.” About GPG | Github Signing our commits is a great way to verify your commits and let your collaborators know that they can trust that you committed those changes in your project....

<span title='2018-08-06 19:47:29 +0000 UTC'>August 6, 2018</span>&nbsp;·&nbsp;5 min&nbsp;·&nbsp;Franccesco Orozco

Deploy a Flask Project to Heroku

I was suddenly in the need of deploying a very basic Flask API to the cloud, so it can be available to the public. The thing is, Flask is not made for a production and scalable environment, but if you only need to deploy a very basic web server to Heroku then this guide is for you. Initialize a repository First of all we will need to set up a virtual enviroment with Pipenv, a Flask app, and initialize a repository....

<span title='2018-05-10 21:26:58 +0000 UTC'>May 10, 2018</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;Franccesco Orozco

Create Multiple Directories With Makedirs in Python

You don’t need a bunch of if’s and else if’s to create an array of directories in python, just the good ol’ makedirs. Create an array of directories To create an array of directories you must import the package os and import the method makedirs >>> from os import makedirs >>> makedirs('1/2/3/4/5') You’ll see now that your directories are created correctly, let’s run the command tree outside of python to see if they’re were actually created....

<span title='2018-04-17 08:43:51 +0000 UTC'>April 17, 2018</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;Franccesco Orozco