ERR: missing stacklevel in to_dict UserWarning
See original GitHub issueCode 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:
- Created 6 years ago
- Comments:7 (7 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yep, probably some others, a sufficiently clever grep might be able to turn them up. (basically whenever we call
warn(...)
without a stacklevel passed.@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 inpandas-dev
.