Skip to content

Tag: pandas

Remove data time older than specific hours

I want to remove data from my dataframe older than say 2 hours from current time starting with 00 mins (datetime column is in index) when i use below code Current datetime: ’17-03-2022 17:05:00′ Issue: My code keeps all records in df from ’17-03-2022 15:05:00′ to ’17-03-2022 17:0…

Control how NAs are displayed with pandas styler

I am trying to use the na_rep argument of df.style.format() to control how cells with NaN are shown in the table. Documentation: https://pandas.pydata.org/docs/reference/api/pandas.io.formats.style.Styler.format.html Reproducible code: I get this error message. TypeError: format() got an unexpected keyword ar…

How to apply function for only special cells in column pandas?

I have a issue with applying function for column in pandas, please see below code : my df now show like below: I would like to apply function checknum for 2 cell in column ‘new’ which is having ‘None’ value. Can someone assist this ? Thank you Answer IIUC, you can use vectorial code: o…