IndexError: only integers, slices (`:`), ellipsis (`…`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

python

Soooo you got the IndexError: only integers, slices (`:`), ellipsis (`…`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices error. Let’s get that annoying message fixed. My Computer Setup For those Short On Time You’re trying to access an element of a Pandas index like df.columns where df is a DataFrame by using …

Read more

Create a Class in Python3

python

So how do you create a class in Python3? What is class? Why do we need a class? All great questions. My Computer Setup Python3 (Finally getting used to adding parentheses around my print statements ) macOS What is an object? So let’s go over what a class is. Classes are the preliminary step to …

Read more

Filter a Pandas DataFrame in Python

python

We’ll be showing you how filter a Pandas DataFrame in Python. So let’s set the scene. You work for a massive food company that sells deli meats and fruits. You’ve been toiling at your computer for hours trying to create a dataframe of your company’s product info. Department XYZ needs that data so they can …

Read more

Clone a Git Repo in Python3

python

So you want to clone a git repo in Python3? I recently came across a case where I wanted to programmatically edit and update a Github repo and what better language to use than Python? My first go at the problem had me thinking of .bat files since I come from a Windows background. Therefore …

Read more

Making A Twitter Bot With Tweepy

python

Want help making a Twitter bot with Tweepy? It’s actually pretty easy after you apply for a developer’s account and setup an app on Twitter’s side. You can do the application and setup here. My Computer Setup Getting your Environment Setup You can find some info on installing pip here. The article actually covers pip installation …

Read more

Modulos in Python

python

Modulos in Python are super useful. They can we be used when we don’t want to print a check each pass during a loop. For example, if I’m looping through 100,000 numbers and want to get an update of how my automation is going every so often instead of printing each loop or blindly running …

Read more

Python Lambda Functions For Idiots

python

What are Python Lambda Functions? They weren’t something I could easily infer from casually seeing it in code or context clues. I had to do a little digging. What I took from my reading, is that they are more concisely written functions. My Setup Example They make this: Into this: I personally think they’re beautiful …

Read more

Drop Duplicates From An Array In Python

python

So, you need to drop duplicates from an array in Python. Maybe you’re iterating through this array and calling an api and need to cut down on the super expensive networking? Regardless, it’s fairly straight forward. My Setup Python 3.xmacOS The Solution We use set() to drop duplicates from an array in Python. A set …

Read more

Unconverted Data Remains Error While Using strptime in Python

python

To start off, screw the unconverted data remains error while using strptime in Python 2.x or 3.x. Of the many Python errors I’ve gotten this has to be one of the more vague ones. That being said, I do hate working with times and dates. Regardless, here’s your solution. My Setup Python 3.xmacOS Recreating the …

Read more