Skip to content

Tag: pandas

How to get which day from date in Python

I have this format of datetime in Python “2022-09-01 08:36:22”, how can I get which weekday of it? I also created this dictionary day_of_week = { 1: “sunday”, 2: “monday”, 3: “tuesday”, 4: “wednesday”, 5: “thursday”, 6: “friday&#822…

Changing one data frame also changes it’s copy

Couldnt come up with a better title, so here we are. I am running the following code: As far as I understand, I first make a copy of ‘df’ and then I change the copy. What makes me confused is that when I run the second line, the ‘date’ column, becomes the index even in the ‘df&#8…

Get index of row where pandas column contains regex

I am checking to see if a pandas column matches a pre-defined regex, using .any() to get the first match if found. However, I need to return the index/row where this match occurred so that I can get the value of another column in that row. I have the below to check where the reg_ex pattern exists in df[&#8216…