Skip to content

BUG: displayed dtype of series inferred from shown subset instead of series #11594

Closed
@jorisvandenbossche

Description

@jorisvandenbossche

All the same issue

In [1]: import datetime

In [2]: s = pd.Series([datetime.datetime(2012, 1, 1)]*10 + [datetime.datetime(1012,1,2)] + [datetime.datetime(2012, 1, 3)]*10)

In [8]: s
Out[8]:
0     2012-01-01 00:00:00
1     2012-01-01 00:00:00
2     2012-01-01 00:00:00
3     2012-01-01 00:00:00
4     2012-01-01 00:00:00
5     2012-01-01 00:00:00
6     2012-01-01 00:00:00
7     2012-01-01 00:00:00
8     2012-01-01 00:00:00
9     2012-01-01 00:00:00
10    1012-01-02 00:00:00
11    2012-01-03 00:00:00
12    2012-01-03 00:00:00
13    2012-01-03 00:00:00
14    2012-01-03 00:00:00
15    2012-01-03 00:00:00
16    2012-01-03 00:00:00
17    2012-01-03 00:00:00
18    2012-01-03 00:00:00
19    2012-01-03 00:00:00
20    2012-01-03 00:00:00
dtype: object

In [9]: pd.options.display.max_rows = 8

In [10]: s
Out[10]:
0    2012-01-01
1    2012-01-01
2    2012-01-01
3    2012-01-01
        ...
17   2012-01-03
18   2012-01-03
19   2012-01-03
20   2012-01-03
dtype: datetime64[ns]

In [11]: s.dtype
Out[11]: dtype('O')

So in some cases, you think you have a datetime64 series, but actually you don't and eg dt properties don't work which can lead to quite some confusion ... :-)

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugMaster TrackerHigh level tracker for similar issuesOutput-Formatting__repr__ of pandas objects, to_string

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions