Skip to content

Groupby max erroneously returns NaN #6346

Closed
@cancan101

Description

@cancan101

Using:

df =pd.read_csv(StringIO(""",Date,app,File
2013-04-23,2013-04-23 00:00:00,,log080001.log
2013-05-06,2013-05-06 00:00:00,,log.log
2013-05-07,2013-05-07 00:00:00,OE,xlsx"""), parse_dates=[0])

This does not work:

In [8]: df.groupby("Date")[["File"]].max()
Out[8]:
                     File
Date
2013-04-23 00:00:00   NaN
2013-05-06 00:00:00   NaN
2013-05-07 00:00:00  xlsx

[3 rows x 1 columns]

but this does:

In [9]: df.groupby("Date")["File"].max()
Out[9]:
Date
2013-04-23 00:00:00    log080001.log
2013-05-06 00:00:00          log.log
2013-05-07 00:00:00             xlsx
Name: File, dtype: object

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions