Python is evolving — don’t get complacent

Photo by Michael Dziedzic on Unsplash

I’ve been coding in Python for more than 10 years. There was a time when I thought I knew it all, which was a clear sign I was getting complacent.

Then I decided to do a bit of research about Python improvements. Those 3.6, 3.7, 3.8 Python versions aren’t there for nothing, right?

After going through release notes, I found these neat tricks that I would like to share with you.

By reading this article, you’ll learn:

  • A better way to work with file paths
  • The proper way of string formating

Here are…


Working from home has its challenges. I use these 7 tips to overcome them.

Photo by Sarah Brown on Unsplash

I’m a full-time Data Scientist. I work from home for the last year and a half. I was extra productive at first (finished with my work earlier) and had more time because I wasn’t commuting. But after some time my productivity started to decline.

Working from home (WFH) is not for everyone. Some feel more productive while others dream about returning to the office.

When I started constantly working during the weekends, I decided it’s time for a change. I analyzed my working routine and slowly started changing it.

These 7 tips are what helped me to change my working…


For each mistake, there’s a proper solution

Library
Library
Photo by Tobias Fischer on Unsplash.

SQL is widely used in data analysis and data science. It’s fairly simple to start writing SQL queries, but bugs can quickly sneak into the code and consequently in the reports (or machine learning models).

In this article, I will show five common mistakes (and solutions) when writing SQL queries. I have made some of these myself, while I noticed others when performing code reviews.

The examples in this article are concise and show the core of the problem with as little code as possible. …


Start using Pandas the way it is intended to be used. Use these 5 tricks to improve pandas code.

Photo by Ilona Froehlich on Unsplash

If you ever worked with pandas, you’re most probably familiar with the richness of pandas library. Pandas enables us to achieve the same goal in multiple ways by using different functions.

The downside of this “richness” is that many of us learned the wrong approach which is hacky, error-prone and might even be deprecated in the future.

In this article, I show 5 pandas tips that will show you the proper way of performing basic operations with pandas.

Intro

Before we start, let’s create a sample DataFrame on which these tips are based:

import pandas as pddf = pd.DataFrame({"col1": ["A0"…


These tips will help you when you need to share your analysis with others

Photo by Sid Balachandran on Unsplash

These tips will help you need to to share your analysis with others. Whether you are a Student, Data Scientist or a Ph.D. Researcher, each project ends with some kind of a report. May this be a post on Confluence, Readme on GitHub or a Scientific paper.

There is no need to copy-paste values one by one from a DataFrame to another software. Pandas with its formatting functions can convert a DataFrame to many formats.

Intro

Let’s create a DataFrame 10 rows and 3 columns with random values.

n = 10
df = pd.DataFrame(
{…


A short tutorial on how to set the colors on a pandas DataFrame.

Photo by Robert Katzki on Unsplash

Pandas needs no introduction as it became the de facto tool for Data Analysis in Python. As a Data Scientist, I use pandas daily and it never ceases to amaze me with better ways of achieving my goals.

Another useful feature that I learned recently is how to color a pandas Dataframe.

Let’s add colors

Let’s create a pandas DataFrame with random numbers:

import numpy as np
import pandas as pd
df = pd.DataFrame(np.random.randint(0, 100, size=(15, 4)), columns=list("ABCD"))


MinMaxScaler can return values smaller than 0 and greater than 1.

Photo by Kelly Sikkema on Unsplash

MinMaxScaler is one of the most commonly used scaling techniques in Machine Learning (right after StandardScaler).

From sklearns documentation:

Transform features by scaling each feature to a given range.

This estimator scales and translates each feature individually such that it is in the given range on the training set, e.g. between zero and one.

Usually, when we use MinMaxScaler, we scale values between 0 and 1.

Did you know that MinMaxScaler can return values smaller than 0 and greater than 1? I didn’t know this and it surprised me.

In case you’re interested, Udacity offers Free Access to:

- Intro to Machine Learning with PyTorch- Deep Learning Nanodegree…


These tips are also applicable to Software Engineers. Make a few changes in your CV and land that job!

Photo by Christina @ wocintechchat.com on Unsplash

Writing a good CV can be one of the toughest challenges of job searching.

Most employers spend just a few seconds scanning each CV before sticking it in the Yes or No pile.

Here are the top 5 tips that will increase the chances that your CV lands in the Yes pile.

In case you’re interested, Udacity offers Free Access to:

- Intro to Machine Learning with PyTorch- Deep Learning Nanodegree and more

1. Beautiful Design


PyTorch and TensorFlow aren’t the only Deep Learning frameworks in Python. There’s another library similar to scikit-learn.

Photo by Uriel SC on Unsplash

scikit-learn is my first choice when it comes to classic Machine Learning algorithms in Python. It has many algorithms, supports sparse datasets, is fast and has many utility functions, like cross-validation, grid search, etc.

When it comes to advanced modeling, scikit-learn many times falls shorts. If you need Boosting, Neural Networks or t-SNE, it’s better to avoid scikit-learn.

scikit-learn has two basic implementations for Neural Nets. There’s MLPClassifier for classification and MLPRegressor for regression.

While MLPClassifier and MLPRegressor have a rich set of arguments, there’s no option to customize layers of a Neural Network (beyond setting the number of hidden…


A 10 step tutorial on how to start and configure a free server anywhere in the world

Photo by Paul Hanaoka on Unsplash

Having an always-on server is a great way to show your references to your future employers or to test your Machine Learning model in the real world.

Before we start I would like to disclose that I’m NOT affiliated with Amazon in any way. The approach you’ll learn in this article should be also applicable to other cloud providers (eg. Microsoft Azure, Google Cloud Platform).

I wrote this article because I feel it is important that you have this knowledge. I wish someone would teach me this in my college days when I had too much time and no money.

By reading this article you’ll learn:

Roman Orac

Senior Data Scientist, tweeting twitter.com/romanorac.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store