I have a data frame with with several columns, one of which is company_name. I'm trying to remove duplicate records based on them having the same company_name, but I'm at a loss on how to do this while maintaining the original case of the company_name.
I've tried converting all names to lowercase and then removing duplicates, but as mentioned before I would like to maintain the original case.
df = pd.DataFrame({'company_name': ['Apple', 'apple', 'BlackBerry', 'blackberry','Blackberry'])
df['company_name'] = df['company_name'].str.strip()
df['company_name'] = df['company_name'].str.lower()
input_records.drop_duplicates(subset=['company_id'], inplace=True,
keep="first")
this code gets rid of duplicates, but stores the company name in all lowercase.
Desired result
company_name
Apple
BlackBerry
Actual result
company_name
apple
blackberry