Skip to content

Tag: pandas

Lag of values from 1 month ago

My initial dataset has only 2 columns, date and value. What I’m trying to do is, for each date, get the value from the previous month (columns m-1 and m-12). The problems I’m having is when the day doesn’t exist in previous month, like 29 of February, that I want to leave it empty, and most …

Distance Matrix Haversine

I am working on a data frame that looks like this : I’m trying to make a Haverisne distance matrix. Basically for each zone, I would like to calculate the distance between it and all the others in the dataframe. So there should be only 0s on the diagonal. Here is the Haversine function that I use but I …

How do I loop column names in a pandas dataframe?

I am new to Python and have never really used Pandas, so forgive me if this doesn’t make sense. I am trying to create a df based on frontend data I am sending to a flask route. The data is looped through and appended for each row. My only problem is that I don’t know how to get the df

Filter dataframe based on 2 columns

I have a big dataframe city Flow Berlin False Berlin True Vienna False Vienna True Vienna False Frankfurt True Frankfurt False I want to remove only the rows where city and flow is Vienna and false using python Resulting dataframe should be city Flow Berlin False Berlin True Vienna True Frankfurt True Frankfu…