df_1['datetime'].dt.dayofyear day of year finding out the day
df = df.rename(columns={'Номер': 'number',
'Дата создания': 'create_date',
'Дата оплаты': 'payment_date',
'Title': 'tittle',
'Статус': 'status',
'Заработано': 'money',
'Город': 'city',
'Платежная система': 'payment_system'})
all_money = df.money.sum()
renaming columns
'Дата создания': 'create_date',
'Дата оплаты': 'payment_date',
'Title': 'tittle',
'Статус': 'status',
'Заработано': 'money',
'Город': 'city',
'Платежная система': 'payment_system'})
all_money = df.money.sum()
renaming columns
money_title = df \
.query("status == 'Завершен'") \
.groupby(['tittle'], as_index=False) \
.aggregate({'money': 'sum', 'number': 'count'}) \
.sort_values('money', ascending=False) \
.rename(columns={'number': 'success_orders'})
today_day = datetime.today().strftime('%Y-%m-%d')
strftime()
.query("status == 'Завершен'") \
.groupby(['tittle'], as_index=False) \
.aggregate({'money': 'sum', 'number': 'count'}) \
.sort_values('money', ascending=False) \
.rename(columns={'number': 'success_orders'})
today_day = datetime.today().strftime('%Y-%m-%d')
strftime()
print(money_by_city.equals(money_by_city2)) equals will make comparsion
pd.read_csv(file_path2, encoding='windows-1251', index_col=0, usecols=['tc', 'art_sp'])
using usecols and index_col for more appropriate way of using
using usecols and index_col for more appropriate way of using
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