Holen Sie sich mehrere Elemente nach Index von jeder Gruppe in Polaren?Python

Python-Programme
Anonymous
 Holen Sie sich mehrere Elemente nach Index von jeder Gruppe in Polaren?

Post by Anonymous »

Wie kann ich in jeder Gruppe eines Polars DataFrame mehrere Elemente nach Index erhalten? Wenn ich beispielsweise das erste und dritte Element jeder Gruppe bekommen wollte, könnte ich so etwas versuchen: < /p>

Code: Select all

import polars as pl

df = pl.DataFrame(dict(x=[1,0,1,0,1,0], y=[1,2,3,4,5,6]))

df.group_by('x').get([0,2])
# AttributeError: 'GroupBy' object has no attribute 'get'
Aber das funktioniert natürlich nicht.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post