def split_brand(brand_name_data):
return brand_name_data.split(' ')[-1]
user_df['brand_name'] = user_df.brand_info.apply(split_brand)
defining the function then applying it on the new column with existing column
return brand_name_data.split(' ')[-1]
user_df['brand_name'] = user_df.brand_info.apply(split_brand)
defining the function then applying it on the new column with existing column
user_df['brand_name'] = user_df.brand_info.apply(lambda brand_name: brand_name.split(' ')[-1]) with lambda applying
users_purchases = users_purchases.query('purchases >= 5') for querying
.agg({'brand_name': pd.Series.nunique}) finding out the unique value
users_purchases \
.merge(users_unique_brands, on='user_id') \
.merge(lovely_brand_purchases_df, on='user_id')
for merge purposes with primary key
.merge(users_unique_brands, on='user_id') \
.merge(lovely_brand_purchases_df, on='user_id')
for merge purposes with primary key
ax = sns.barplot(x="lovely_brand", y="user_id", data=brands_loyalty) barplot
df[
~(df['workingday'] == 0)
&(df['temp'] >= 10)
&(df['temp'] < 30)
] with working filtering
~(df['workingday'] == 0)
&(df['temp'] >= 10)
&(df['temp'] < 30)
] with working filtering
pd.set_option('display.max_rows', 85, index_col ="Column") for showing out the all indexes in table
df.sort_values(by=['Country', 'ConvertedCp,'], ascending=[True, False], inplace = True) sorting advanced
country_grp['Salary'].median().loc['Germany'] Germany country looking for the Salary
country_uses_python = country_grp['LanguageWorkedWith'].apply(lambda x: x.str.contains('Python').sum())
where Python word contains
where Python word contains
df.apply(len, axis='columns')
df['email'].apply(len)
len(df['email'])
df['email'].apply(len)
len(df['email'])
df['full_name'] = df['first'] + '' + df['last']
adding columsn
adding columsn
df.drop(columns = ['first', ' last'], inplace = True)
removing column
removing column
df[['first', 'last']] = df['full_name'].str.split(' ', expand = True)
mergin two columns as one
mergin two columns as one
df.dropna(axis ='index', how ='all', subset=['last', 'email'])
droping null values with specfiying indexes
droping null values with specfiying indexes