I am trying to create a list of year-quarters in python; per the documentation (https://pandas.pydata.org/docs/reference/api/pandas.Period.strftime.html), %q (I believe) should output an integer representation of calendar quarter, but instead the output I get is just %q literally. Input: Expected Output: Actual Output: Answer The %q formatter is specific to Period.strftime, so it must be used with Period data: The method recognizes
Tag: strftime
Unexpected datetime behavior
I have a Django project where I used the strftime function like this in models.py: However, for some reason this returns a ValueError, even though according to a documentation (https://www.programiz.com/python-programming/datetime/strftime) this is a valid format string. Once I removed all the dashes, it worked normally. Why doesn’t this work? Do I need to import a module or something? Thanks. Answer