Horje
combining sparse class Code Example
combining sparse class
categorical_features=[feature for feature in dataset.columns if dataset[feature].dtype=='O']
for feature in categorical_features:   
    temp=dataset[feature].value_counts(normalize=True)
    temp_df=temp[temp>0.01].index                     
    
    dataset[feature]=np.where(dataset[feature].isin(temp_df),dataset[feature],'Rare_var')
                                   # condition satisfies then   'X'            else'Y'
                                   #condition---------->   ,take this values else,'Rare_var'




Python

Related
django command to fetch all columns of a table Code Example django command to fetch all columns of a table Code Example
concatenate the next row to the previous row pandas Code Example concatenate the next row to the previous row pandas Code Example
funtools rougly equivalent to, internal Code Example funtools rougly equivalent to, internal Code Example
extract link from text python Code Example extract link from text python Code Example
The readlines() method returns Code Example The readlines() method returns Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7