Skip to content

df.head() and .tail() weirdness #5370

Closed
@michaelaye

Description

@michaelaye

I am data wrangling some Excel data into a dataframe.

At some point it has an Index like so:

Index([u'(K)', -440.0, -439.0, -438.0, -437.0, -436.0, -435.0, -434.0, -433.0, -432.0], dtype='object')

Naturally, I want to drop the "u'(K)'" index. Interestingly, after doing so the head() and tail() calculation totally goes haywire, and that irrespective of using this Index with dtype object or after converting it to the new Float64Index.:

<class 'pandas.core.frame.DataFrame'>
Float64Index: 446 entries, -440.0 to 5.0
Data columns (total 7 columns):
Channel 3 (A3)    446  non-null values
Channel 4 (A4)    446  non-null values
Channel 5 (A5)    446  non-null values
Channel 6 (A6)    446  non-null values
Channel 7 (B1)    446  non-null values
Channel 8 (B2)    446  non-null values
Channel 9 (B3)    446  non-null values
dtypes: float64(7)

or before, with dtypes still as 'object':

<class 'pandas.core.frame.DataFrame'>
Float64Index: 446 entries, -440.0 to 5.0
Data columns (total 7 columns):
Channel 3 (A3)    446  non-null values
Channel 4 (A4)    446  non-null values
Channel 5 (A5)    446  non-null values
Channel 6 (A6)    446  non-null values
Channel 7 (B1)    446  non-null values
Channel 8 (B2)    446  non-null values
Channel 9 (B3)    446  non-null values
dtypes: object(7)

I think I can see what's happening here: The head calculation somehow picks up the 5.0 value in the Index and choses to display the dataframe until then. Which now makes me question: Did the API of head() change and I didn't notice? My apologies if this actually is a case of PEBKAC.

The process of my data wrangling can be seen here:
http://nbviewer.ipython.org/7208717

pandas version: '0.12.0-1000-gea97682'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions