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.

Bizarre errors from Pandas when using the decorator

See original GitHub issue

Wanted to use this but I get bizarre errors from Pandas when I add the decorator to my test function.

The test and the code being tested do not execute any Pandas methods directly, but one of my project modules imports pandas - the error is occurring at import time.

  File "/Users/anentropic/Documents/Dev/Work/anentropic/backend/stats/users.py", line 6, in <module>
    import pandas as pd
  File "/Users/anentropic/.virtualenvs/anentropic/lib/python2.7/site-packages/pandas/__init__.py", line 7, in <module>
    from . import hashtable, tslib, lib
  File "pandas/tslib.pyx", line 614, in init pandas.tslib (pandas/tslib.c:81486)
  File "pandas/tslib.pyx", line 573, in pandas.tslib.NaTType.__new__ (pandas/tslib.c:12539)
TypeError: __new__() takes exactly one argument (4 given)

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

16reactions
ze-phyr-uscommented, Jan 28, 2016

Just ran into this problem too – my frozen test code was importing Pandas, and Pandas import failed with

TypeError: type 'pandas.tslib._Timestamp' is not dynamically allocated but its base type 'FakeDatetime' is dynamically allocated

I got it to work by explicitly importing Pandas before the test code runs.

12reactions
bhrutledgecommented, Feb 24, 2020

To give a concrete example of this suggestion from @ze-phyr-us:

I got it to work by explicitly importing Pandas before the test code runs.

I was able to do this by adding import pandas to my global conftest.py.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The @profile decorator from memory_profiler is changing the ...
I am using the library memory_profiler to run some memory profiling and it seems to works fine, except if I use the @profile...
Read more >
5 Advanced Tips on Python Decorators | by Michael Berk
In chapter 7 of Fluent Python, Luciano Ramalho discusses decorators and closures. They are not super common in basic DS work, however as...
Read more >
Primer on Python Decorators
Decorating Classes; Nesting Decorators; Decorators With Arguments; Both Please, But Never Mind the ... Unfortunately, running this code raises an error:.
Read more >
Error Handling in Python using Decorators - GeeksforGeeks
Error Handling in Python using Decorators ; def decorator_example(func):. print ( "Decorator called" ). # defining inner decorator function. def ...
Read more >
Error with Table.from_pandas - Hail Query & hailctl
Hi I'm using hail 0.2.83 and am having a problem with creating a table from a ... pop_clf File <decorator-gen-1085>:2, in from_pandas(df, ...
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