Skip to content

Tag: python

Join two columns of sequentially values

I have dataframe, where ‘A’ 1 – client, B – admin I need to merge messages in row with 1 sequentially and merge lines 2 – admin response sequentially across the dataframe. I do not know how to do this Answer Create groups by consecutive values in B – trick compare shifted v…

Sqlalchemy in-memory database for MSSQL

I’m trying to setup tests for my project and want to use an in memory database for those tests. Based on some examples I found online I’ve been able to get an in memory sqlite database working… The problem I have is my models are all based around MSSQL (that’s what the ‘real&#821…

Calculate the total days between a range of dates using Python

I have a list of date ranges and want to find the total number of days between those ranges. However, the ranges may, or may not, have overlap. And I want to exclude overlapped time. There may also be gaps between the ranges which I also want to exclude. I’m curious on the most optimal way to calculate …

keep the same name until value = true in another pandas column

I have a dataframe with 3 columns: session_id, name, reset_flag. I need to make a new column, new_name, where the new name will be set to the first name where reset_flag=True, and then it will continue as that name WITHIN that session, until there is new reset_flag. Not really sure best way to approach. EDIT:…