Skip to content
Advertisement

How to remove timestamp from datetime column in pandas Style Object

I have a DataFrame with a Date column that has no timestamp:

date without timestamp

But once I apply style to another column in the df, e.g. :

JavaScript

The DataFrame becomes a Style Object, and the “Date” column gets a timestamp that it didn’t have before, as the following:

enter image description here

I tried the following to strip the timestamp from the Date column:

JavaScript

I got the following error:

JavaScript

Is there any way to remove the time stamp from the Style object?

Advertisement

Answer

This is just a stopgap solution, but you can manually specify the usual %Y-%m-%d display format for your date column as follows:

JavaScript

Example

JavaScript

Styler with unexpected datetime display format

JavaScript

Styler with manually fixed datetime display format

Advertisement