Skip to content
Advertisement

Tag: dataframe

Pandas: str.extract() giving unexpected NaN

I have a data set which has a column that looks like this I need only the numbers. Here’s my code: I was expecting an output like: but I got Just to test, I dumped the dataframe to a .csv and read it back with pd.read_csv(). That gave me just the numbers, as I need (though of course that’s not

Update column based on grouped date values

Edited/reposted with correct sample output. I have a dataframe that looks like the following: This dataframe is split into groups by ID. I would like to make an updated combined column based on if df[‘bool’] == True, but only if df[‘bool’] == True AND there is another ‘finished’ row in the same group with a LATER (not the same) year.

Advertisement