This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sub_brand_finder(subcategory): | |
temp=cscp[cscp['PrimaryCategory']=='Makeup Products (non-permanent)'] | |
df=temp[temp['SubCategory']==subcategory].groupby('brandname').agg({'ChemicalCount':np.mean,'BrandName':'first'}).sort_values('ChemicalCount').reset_index() | |
least=str(np.array(df.head(3)['BrandName']))[1:-1] | |
most=str(np.array(df.tail(3)['BrandName']))[1:-1] | |
text1 = "\033[32m" | |
text2 = "\033[31m" | |
print("\033[1m",text1,'The three most chemical-safe brands in '+subcategory+' are '+least) | |
print("\033[1m",text2,'The three least chemical-safe brands in '+subcategory+' are '+most) | |
for i in makeup_subcategories: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def brand_finder(category): | |
df=cscp[cscp['PrimaryCategory']==category].groupby('BrandName').agg(np.mean).sort_values('ChemicalCount').reset_index() | |
least=str(np.array(df.head(3)['BrandName']))[1:-1] | |
most=str(np.array(df.tail(3)['BrandName']))[1:-1] | |
text1 = "\033[32m" | |
text2 = "\033[31m" | |
print("\033[1m",text1,'The three most chemical-safe brands in '+category+' are '+least) | |
print("\033[1m",text2,'The three least chemical-safe brands in '+category+' are '+most) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cscp.groupby('ChemicalName').size().to_frame().rename({0:'count'},axis=1).sort_values('count',ascending=False).head(5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
most_chemical_brands=chemical_count.sort_values('ChemicalCount',ascending=False).query('ChemicalCount>2') | |
most_chemical_brands.head(5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cscp['BrandName']=cscp['BrandName'].str.lower().str.replace('.','').str.replace(' ','').str.replace('�','') | |
cscp['ProductName']=cscp['ProductName'].str.lower() | |
cscp['ChemicalName']=cscp['ChemicalName'].str.lower() |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.