Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Period with nanoseconds (?) #17053

Closed
ChadFulton opened this issue Jul 22, 2017 · 4 comments · Fixed by #38175
Closed

BUG: Period with nanoseconds (?) #17053

ChadFulton opened this issue Jul 22, 2017 · 4 comments · Fixed by #38175
Labels
Milestone

Comments

@ChadFulton
Copy link

Code Sample, a copy-pastable example if possible

p = pd.Period('2000-01-01 00:00:00.123456789', freq='N')
print(p.freq)
print(p)
print(p + pd.Timedelta(789, 'ns'))

This results in:

<Nano>
2000-01-01 00:00:00.123456000
2000-01-01 00:00:00.123456789

Problem description

From my reading of the docs, it appears that Period objects should accept nanosecond input, and they appear to support it, above, using Timedeltas.

The problem is that it appears to truncate the input strings.

Expected Output

<Nano>
2000-01-01 00:00:00.123456789
2000-01-01 00:00:00.123457578

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 2.7.6.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
LOCALE: None.None

pandas: 0.20.3
pytest: None
pip: 9.0.1
setuptools: 21.0.0
Cython: 0.24
numpy: 1.13.1
scipy: 0.18.0.dev0+46034f7
xarray: None
IPython: 5.0.0b4
sphinx: 1.4.4
patsy: 0.2.1
dateutil: 2.2
pytz: 2016.4
blosc: None
bottleneck: None
tables: None
numexpr: 2.4
feather: None
matplotlib: 2.0.0rc2
openpyxl: 1.8.6
xlrd: 0.9.2
xlwt: None
xlsxwriter: None
lxml: 3.4.0
bs4: 4.3.2
html5lib: None
sqlalchemy: 1.0.14
pymysql: None
psycopg2: 2.6.1 (dt dec pq3 ext lo64)
jinja2: 2.8
s3fs: None
pandas_gbq: None
pandas_datareader: 0.2.1

@chris-b1
Copy link
Contributor

Honestly not sure if a nanosecond Period is really supported, but if it's not, this should raise, so buggy either way.

For what it's worth our Timestamp is essentially equivalent to a nanosecond Period so may be a reasonable substitute depending on your use-case.

@chris-b1 chris-b1 added API Design Bug Period Period data type labels Jul 23, 2017
@ChadFulton
Copy link
Author

It's not a big problem; I'm just trying to fix an issue in statsmodels when users specify indexes that run up against the min or max Timestamp values and write some unit tests. We try to delegate all the date / time handing to Pandas operations, so I was just hoping to understand when I could use PeriodIndexes to get around the Timestamp limitations.

@jreback
Copy link
Contributor

jreback commented Jul 26, 2017

this should work, seems there is some truncation to the microsecond level.

@jreback jreback added this to the Next Major Release milestone Jul 26, 2017
@jreback
Copy link
Contributor

jreback commented Jul 26, 2017

original change was #3060

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants