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.

ENH: support pendulum objects

See original GitHub issue
import pendulum
import pandas
pandas.date_range(start=pendulum.now(), end=pendulum.tomorrow())

[1]    56829 segmentation fault  ipython

Problem description

As pendulum claims to inherit from datetime.datetime, I wouldn’t expect a segfaut to happen, as date_range always worked find with datetime objects

From the documentation:

The Pendulum class is a drop-in replacement for the native datetime class (it is inherited from it).

I could file an issue on the pendulum bug tracker as well, but that’s pandas who’s segfaulting, so I think you guys would have better tools to understand what’s going on.

Expected Output

DatetimeIndex(['2017-04-12 20:54:52.305104', '2017-04-13 20:54:52.305104'], dtype='datetime64[ns]', freq='D')

Output of 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: fr_BE.UTF-8 LOCALE: fr_BE.UTF-8

pandas: 0.19.2 nose: None pip: 9.0.1 setuptools: 34.4.1 Cython: None numpy: 1.12.1 scipy: None statsmodels: None xarray: None IPython: 5.3.0 sphinx: None patsy: None dateutil: 2.6.0 pytz: 2017.2 blosc: None bottleneck: None tables: None numexpr: None matplotlib: None openpyxl: None xlrd: 1.0.0 xlwt: None xlsxwriter: None lxml: None bs4: None html5lib: None httplib2: None apiclient: None sqlalchemy: 1.1.9 pymysql: None psycopg2: 2.6.2 (dt dec pq3 ext lo64) jinja2: 2.9.6 boto: None pandas_datareader: None

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

10reactions
sdispatercommented, Jul 13, 2017

@jreback Author of pendulum here 😃 What do you mean by it does not use standard timezone?

>>> isinstance(pendulum.now().tzinfo, datetime.tzinfo)
True

So, as you can see, pendulum uses a subclass of the standard tzinfo.

The underlying problem comes from pandas since it calls:

int(total_seconds(_get_utcoffset(tz, None)))

in the _get_dst_info() function.

However total_seconds() assumes a timedelta while the utcoffset() method of a tzinfo can also return None.

Here is what the offical Python documentation says (https://docs.python.org/3.6/library/datetime.html#datetime.tzinfo.utcoffset):

If the UTC offset isn’t known, return None.

And in this case None is being passed to utcoffset() so there is no way to determine the offset that’s why pendulum returns None.

So None is a valid return value, however pandas will segfault when it occurs.

8reactions
philsheardcommented, Oct 2, 2020

I see that the Pendulum issue has been closed without a fix, so if anyone wants a workaround to this:

I did a roundtrip from Pendulum > ISO format > Pandas to avoid the internal lookup that causes the warning.

converted_date = pandas.to_datetime(pendulum.today().isoformat())

Not pretty but it will clean your error logs without hurting comprehension.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Damping of a Simple Pendulum Due to Drag on Its String
Experimentally it is found that for a relatively small object moving in air with speeds less than about 24 m/s, the force of...
Read more >
Energy in a Pendulum | Gary Garber's Blog
In a simple pendulum with no friction, mechanical energy is conserved. Total mechanical energy is a combination of kinetic energy and gravitational potential ......
Read more >
Electrical Energy Harvesting By Using Pendulum Power ...
pendulum based power generation system in real time application wherever the vibration produced ... This law is state that “An object at rest...
Read more >
Pendulum with an Oscillating Support
Make Your Own Copy. WOLFRAM|DEMONSTRATIONS PROJECT. Pendulum with an Oscillating Support. ​. angular velocity. π. 2. oscillation amplitude ...
Read more >
The Project Gutenberg eBook of Development of Gravity ...
GRAVITY PENDULUM: a precisely made pendulum used for the measurement of gravity. COMPOUND PENDULUM: a pendulum in which the supporting rod is ...
Read more >

github_iconTop Related Medium Post

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