I know there are several ways to convert a column to a date object, but what I am looking for is a way to do so while simultaneously formatting other columns. Say I have the following data frame:
import pandas as pd
url = "https://raw.github.com/pandas-dev/pandas/master/pandas/tests/data/tips.csv"
df = pd.read_csv(url)
df["date"] = list(range(42005, 42005+len(df)))
What I'm trying to achieve is the ability to print these data using some formatting, so I might do something like the following:
print(
df
.head(10)
.to_string(
formatters={"total_bill": "${:,.2f}".format,
"tip": "${:,.2f}".format
}
)
)
But I also want to format the date in this step as well. I tried looking through here for what I was looking for, but the datetime options didn't seem like they would work in what I'm trying to do, and building a custom option is a bit outside scope for my target audience.
Is it possible to do this in a simple manner?