Skip to content

Tag: pandas

Filter pandas column based on ranges in a huge list

Trying to filter ‘time’ data into ‘time_filtered’ based on lut_lst ranges, ergo if ‘time’ value falls in any of the ranges, exchange with NaN otherwise copy value into new column. The output for df is not filtered. I tried using any(lut_lst) or all(lut_lst) but that just th…

select pandas rows based on 2 conditions using or

I have a pandas dataframe filled with values between 0 and 3 and now I would like to either select the max value and return the column label or return ‘undecided’ if a row does only contain 0 and 1 across multiple columns. so far I have the first part sorted: How do I write the second part? My dat…

Begginer/ numpy where and copy

I am trying to copy values from one Field2 into Field1 if Field1 is null or NaN. I have tried below where statement as per documentation, but it cuts outliners instead of copyting the value. dataframe=np.where(dataframe[‘field1’].isnull(),np.copy(dataframe[‘field2’]),1) I have interpre…

Output missing dates by group of columns

I have time series of y per store and product stored in the following dataframe: I would like to output all the missing dates per store, product and return the following result: Answer Use groupby_resample: Details: Update: If you have a date in the ds column without a value in the y column, just use fillna({…