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.

ERR: missing stacklevel in to_dict UserWarning

See original GitHub issue

Code Sample, a copy-pastable example if possible

In [4]: df = pd.DataFrame([[1,2,3]], columns=['a', 'a', 'b'])

In [5]: df
Out[5]:
   a  a  b
0  1  2  3

In [6]: df.to_dict()
C:\<snip>\pandas\core\frame.py:891:
UserWarning: DataFrame columns are not unique, some columns will be omitted.
  "columns will be omitted.", UserWarning)
Out[6]: {'a': {0: 2}, 'b': {0: 3}}

Problem description

warning should specific stacklevel to warn at calling site, xref #9584

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
chris-b1commented, Jul 14, 2017

Yep, probably some others, a sufficiently clever grep might be able to turn them up. (basically whenever we call warn(...) without a stacklevel passed.

0reactions
imihcommented, Jul 15, 2017

@TomAugspurger You’re refering to @deprecate_kwarg. @deprecate is something else. https://github.com/pandas-dev/pandas/blob/master/pandas/util/_decorators.py#L9 and it’s not currently in use in pandas-dev.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to suppress the stacklevel in python warnings module
If I do warnings.warn(...) I get something like this: as.py:80: UserWarning: Value of 16777215 shortened to 8-bit value of 255 ...
Read more >
Source code for pandas.core.frame - OMFIT
UserWarning, stacklevel=2, ) # GH16122 into_c ... TypeError) as err: raise ValueError( "Cannot set a frame with no defined index " "and a ......
Read more >
Changelog — Python 3.11.1 documentation
Paths are no longer encoded to UTF-8/strict to avoid encoding errors if it contains surrogate characters (bytes paths are decoded with the surrogateescape...
Read more >
Version 0.19.0 (October 2, 2016) — pandas 1.5.2 documentation
An UnsupportedFunctionCall error is now raised if NumPy ufuncs like np.mean are called on groupby or resample objects (GH12811). __setitem__ will no longer ......
Read more >
Source code for pandas.core.categorical
RuntimeWarning, stacklevel=2) self.set_ordered(ordered or False, inplace=True) ... DEPRECATED: calling this method will raise an error in a future release.
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