question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

QuarterBegin wrong date

See original GitHub issue

Would expect this to point to one of (1, 4, 7, 10)…

#### Code Sample, a copy-pastable example if possible
import pandas as pd
pd.Timestamp.today() - pd.tseries.offsets.QuarterBegin()
>Timestamp('2016-09-01 15:29:06.556269')

#### Expected Output
Timestamp('2016-07-01 15:29:06.556269')

#### output of ``pd.show_versions()``
In [4]: pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 3.5.2.final.0
python-bits: 64
OS: Darwin
OS-release: 15.6.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.18.1
nose: None
pip: 8.1.2
setuptools: 25.1.6
Cython: None
numpy: 1.11.1
scipy: None
statsmodels: None
xarray: None
IPython: 5.1.0
sphinx: None
patsy: None
dateutil: 2.5.3
pytz: 2016.6.1
blosc: None
bottleneck: None
tables: 3.2.3.1
numexpr: 2.6.1
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.13
pymysql: None
psycopg2: 2.6.2 (dt dec pq3 ext lo64)
jinja2: 2.8
boto: None
pandas_datareader: None

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:16 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
chris-b1commented, Sep 19, 2016

The default anchor month for QuarterBegin is 3 (6, 9, 12). It sounds like you want it anchored at 1, if so, use the startingMonth keyword arg. Docs could be better here.

qtr = pd.tseries.offsets.QuarterBegin(startingMonth=1)

pd.Timestamp.today() - qtr
Out[13]: Timestamp('2016-07-01 16:06:23.581744')
0reactions
chris-b1commented, Sep 20, 2016

Those are the defined semantics - n=1 always rolls forward. http://pandas.pydata.org/pandas-docs/stable/timeseries.html#anchored-offset-semantics

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pandas QuarterBegin(): Possible Bug when calculating First of ...
import pandas as pd print(" date Quarter Quarter begin Quarter end ") for yr in range(2020, 2021): for mo in range(1,13): for dy...
Read more >
Clarification on DateOffset and QuarterBegin, QuarterEnd
Hi,. I thought that the following would give me the quarter start and end date for a particular date. start = mydate -...
Read more >
pandas.tseries.offsets.QuarterBegin
DateOffset increments between Quarter start dates. startingMonth = 1 corresponds to dates like 1/01/2007, 4/01/2007, … startingMonth = 2 corresponds to dates ......
Read more >
Possible Bug when calculating First of quarter-Pandas,Python
Coding example for the question Pandas QuarterBegin(): Possible Bug when ... import pandas as pd print(" date Quarter Quarter begin Quarter end ")...
Read more >
Determining Quarter? - Mibuso Forum
Now I have created two new variables:- QuarterBegin (date) and ... Also, right now it gives me an error that the type of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found