Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add (implicit) handling for torch tensors in is_scalar (#14623)
PyTorch tensors advertise that they support the number API, and hence answer "True" to the question pd.api.types.is_scalar(torch_tensor). This trips up some of our data ingest, since in as_index we check if the input is a scalar (and raise) before handing off to as_column. To handle this, if we get True back from pandas' is_scalar call, additionally check that the object has an empty shape attribute (if it exists). See also: - pytorch/pytorch#99646 - pandas-dev/pandas#52701 Authors: - Lawrence Mitchell (https://github.com/wence-) Approvers: - Ashwin Srinath (https://github.com/shwina) URL: #14623
- Loading branch information