Change panda date format into another date format?

Viewed 21

How do I convert this format below into the result format ?

import pandas as pd 
date = pd.date_range('2022-01-01',2022-01-31', freq = 'H')

Result:

'2021-01-01T01%3A00%3A00',

What is the correct name for the result time format ? Have tried using urlilib.parse module, but it did not have T and it can take 1 date.

Thank you !

1 Answers

This so called url encode , so we need urllib, notice here %3A = ':'

import urllib
date.astype(str).map(urllib.parse.quote)
Out[158]: 
Index(['2022-01-01%2000%3A00%3A00', '2022-01-01%2001%3A00%3A00',
....
Related