A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/12336 below:

Initializing category with single value raises AttributeError · Issue #12336 · pandas-dev/pandas · GitHub

    In [2]: pd.Series([0,0,0], dtype="category")
    Out[2]: 
    0    0
    1    0
    2    0
    dtype: category
    Categories (1, int64): [0]

    In [3]: pd.Series(0, index=range(3), dtype="category")
    ---------------------------------------------------------------------------
    AttributeError                            Traceback (most recent call last)
    <ipython-input-3-2c1d7a241071> in <module>()
    ----> 1 pd.Series(0, index=range(3), dtype="category")

    /home/nobackup/repo/pandas/pandas/core/series.pyc in __init__(self, data, index, dtype, name, copy, fastpath)
        224             else:
        225                 data = _sanitize_array(data, index, dtype, copy,
    --> 226                                        raise_cast_failure=True)
        227 
        228                 data = SingleBlockManager(data, index, fastpath=True)

    /home/nobackup/repo/pandas/pandas/core/series.pyc in _sanitize_array(data, index, dtype, copy, raise_cast_failure)
       2961             if len(subarr) != len(index) and len(subarr) == 1:
       2962                 subarr = create_from_value(subarr[0], index,
    -> 2963                                            subarr.dtype)
       2964 
       2965     elif subarr.ndim > 1:

    /home/nobackup/repo/pandas/pandas/core/series.pyc in create_from_value(value, index, dtype)
       2929         else:
       2930             if not isinstance(dtype, (np.dtype, type(np.dtype))):
    -> 2931                 dtype = dtype.dtype
       2932             subarr = np.empty(len(index), dtype=dtype)
       2933             subarr.fill(value)

    AttributeError: 'CategoricalDtype' object has no attribute 'dtype'

(Not a particularly brilliant use of categories, but they can then be concatenated with others.)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4