“Pandas DataFrame Ogranicz wiersze według wartości Col” Kod odpowiedzi

Pandas DataFrame Ogranicz wiersze według wartości Col

# Reduce the DataFrame to Equal Count of Label Types
min = df.label.value_counts().min()
df = df.groupby('label').head(min).reset_index()
Roggen Brot

Ogranicz wpisy w kolumnie DataFrame

DataFrame.clip(lower=None, upper=None, axis=None, inplace=False, *args, **kwargs)
Real Raccoon

Python DataFrame Ogranicz wiersze

# Import pandas package 
import pandas as pd 
    
# Define a dictionary containing employee data 
data = {'Name':['Jai', 'Princi', 'Gaurav', 'Anuj'], 
        'Age':[27, 24, 22, 32], 
        'Address':['Delhi', 'Kanpur', 'Allahabad', 'Kannauj'], 
        'Qualification':['Msc', 'MA', 'MCA', 'Phd']} 
    
# Convert the dictionary into DataFrame  
df = pd.DataFrame(data) 
    
# select three rows and two columns 
print(df.loc[1:3, ['Name', 'Qualification']])
Defiant Dove

Odpowiedzi podobne do “Pandas DataFrame Ogranicz wiersze według wartości Col”

Pytania podobne do “Pandas DataFrame Ogranicz wiersze według wartości Col”

Więcej pokrewnych odpowiedzi na “Pandas DataFrame Ogranicz wiersze według wartości Col” w Python

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu