Skip to content

BUG: invalid constrution of a Series with dtype=str #19853

Closed
@jamesqo

Description

@jamesqo
pd.Series('', dtype=str, index=range(1000))

throws a ValueError with the following message:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\james\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pandas\core\series.py", line 266, in __init__
    data = SingleBlockManager(data, index, fastpath=True)
  File "C:\Users\james\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pandas\core\internals.py", line 4402, in __init__
    fastpath=True)
  File "C:\Users\james\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pandas\core\internals.py", line 2957, in make_block
    return klass(values, ndim=ndim, fastpath=fastpath, placement=placement)
  File "C:\Users\james\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pandas\core\internals.py", line 2082, in __init__
    placement=placement, **kwargs)
  File "C:\Users\james\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pandas\core\internals.py", line 111, in __init__
    raise ValueError('Wrong number of dimensions')
ValueError: Wrong number of dimensions

Would it be possible to fix the behavior to initialize the series to '' (or at least provide a clearer message)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDtype ConversionsUnexpected or buggy dtype conversionsReshapingConcat, Merge/Join, Stack/Unstack, ExplodeStringsString extension data type and string data

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions