Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

displot(.., rug=True) results in TypeError with pd.Timestamp data #2510

Closed
nocluebutalotofit opened this issue Mar 17, 2021 · 1 comment
Closed

Comments

@nocluebutalotofit
Copy link

The following code:

import seaborn as sb
import pandas as pd

df = pd.DataFrame( {0: {976: pd.Timestamp('2021-03-10 00:00:00'), 1135: pd.Timestamp('2021-03-10 00:00:00'), 688: pd.Timestamp('2021-03-10 00:00:00'), 260: pd.Timestamp('2005-01-07 00:00:00'), 30: pd.Timestamp('2006-03-31 00:00:00'), 86: pd.Timestamp('2021-03-10 00:00:00'), 213: pd.Timestamp('2021-03-10 00:00:00'), 659: pd.Timestamp('2021-03-10 00:00:00'), 1007: pd.Timestamp('2021-03-10 00:00:00'), 211: pd.Timestamp('2021-03-10 00:00:00')}} )

sb.displot(data=df.loc[:,0], rug=True)

results in:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-63-15474ccedd7d> in <module>
      4 df = pd.DataFrame( {0: {976: pd.Timestamp('2021-03-10 00:00:00'), 1135: pd.Timestamp('2021-03-10 00:00:00'), 688: pd.Timestamp('2021-03-10 00:00:00'), 260: pd.Timestamp('2005-01-07 00:00:00'), 30: pd.Timestamp('2006-03-31 00:00:00'), 86: pd.Timestamp('2021-03-10 00:00:00'), 213: pd.Timestamp('2021-03-10 00:00:00'), 659: pd.Timestamp('2021-03-10 00:00:00'), 1007: pd.Timestamp('2021-03-10 00:00:00'), 211: pd.Timestamp('2021-03-10 00:00:00')}} )
      5 
----> 6 sb.displot(data=df.loc[:,0], rug=True)

~/anaconda3/envs/env_system/lib/python3.8/site-packages/seaborn/distributions.py in displot(data, x, y, hue, row, col, weights, kind, rug, rug_kws, log_scale, legend, palette, hue_order, hue_norm, color, col_wrap, row_order, col_order, height, aspect, facet_kws, **kwargs)
   2286         if color is not None:
   2287             rug_kws["color"] = color
-> 2288         p.plot_rug(**rug_kws)
   2289 
   2290     # Call FacetGrid annotation methods

~/anaconda3/envs/env_system/lib/python3.8/site-packages/seaborn/distributions.py in plot_rug(self, height, expand_margins, legend, **kws)
   1310 
   1311             if "x" in self.variables:
-> 1312                 self._plot_single_rug(sub_data, "x", height, ax, kws)
   1313             if "y" in self.variables:
   1314                 self._plot_single_rug(sub_data, "y", height, ax, kws)

~/anaconda3/envs/env_system/lib/python3.8/site-packages/seaborn/distributions.py in _plot_single_rug(self, sub_data, var, height, ax, kws)
   1338 
   1339             trans = tx.blended_transform_factory(ax.transData, ax.transAxes)
-> 1340             xy_pairs = np.column_stack([
   1341                 np.repeat(vector, 2), np.tile([0, height], n)
   1342             ])

<__array_function__ internals> in column_stack(*args, **kwargs)

~/anaconda3/envs/env_system/lib/python3.8/site-packages/numpy/lib/shape_base.py in column_stack(tup)
    654             arr = array(arr, copy=False, subok=True, ndmin=2).T
    655         arrays.append(arr)
--> 656     return _nx.concatenate(arrays, 1)
    657 
    658 

<__array_function__ internals> in concatenate(*args, **kwargs)

TypeError: invalid type promotion

with rug=False no error is thrown.

sb.version = '0.11.0'

@mwaskom
Copy link
Owner

mwaskom commented Mar 17, 2021

This works on master (#2458):

image

@mwaskom mwaskom closed this as completed Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants