Coding skills here for learning
6 subscribers
266 photos
3 files
10 links
Download Telegram
df_1[df_1['datetime'].dt.month == 5] month extraction
rents_by_week = df_1.groupby(
df_1['datetime'].dt.weekofyear
).agg({
'temp': 'count'
})
# sample(10) - это взять 10 случайных записей
# Чтобы была воспроизводимость, фиксируем random_state
rents_by_week.sample(10, random_state=42)
ax = rents_by_week.hist(bins=100, figsize=(16, 9))
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
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()
pd.read_csv(file_path, encoding='windows-1251' , sep=';')
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
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
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
ax = sns.barplot(x="lovely_brand", y="user_id", data=brands_loyalty) barplot
dropna() for dropping null values
df[
~(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['ConvertedCp'].nlargest() finding out the max()
df.sort_values(by=['Country', 'ConvertedCp,'], ascending=[True, False], inplace = True) sorting advanced