df3_g = df3 \
.groupby(['StockCode', 'Description'], as_index=False) \
.aggregate({'Quantity': 'count'}) \
.sort_values('Quantity', ascending=False)
df3_g
grouping by sorting and agg
.groupby(['StockCode', 'Description'], as_index=False) \
.aggregate({'Quantity': 'count'}) \
.sort_values('Quantity', ascending=False)
df3_g
grouping by sorting and agg
df3.loc[:, 'Revenue'] = df3['Quantity'] * df3['UnitPrice']
df3
using loc with: only which stands for all then with comma, using column name for assigning it
df3
using loc with: only which stands for all then with comma, using column name for assigning it
df3_total_Revenue = df3 \
.groupby('InvoiceNo')['Revenue'].sum()
using groupby by Invoice No which means individually and by Revenue which totally means Individual Income
.groupby('InvoiceNo')['Revenue'].sum()
using groupby by Invoice No which means individually and by Revenue which totally means Individual Income
pd.to_datetime(ads_data.time, unit='s') with this you will make seconds carefully look
ads_data.groupby('date') \
.agg({'ad_id': 'count'}).plot()
using groupby and aggregating and ploting
.agg({'ad_id': 'count'}).plot()
using groupby and aggregating and ploting
ads_data.groupby(['date', 'event'], as_index=False) \
.agg({'ad_id': 'count'}) \
.pivot(index='date', columns='event', values='ad_id')\
.reset_index()
using groupby and pivoting by date and event and ad_id
.agg({'ad_id': 'count'}) \
.pivot(index='date', columns='event', values='ad_id')\
.reset_index()
using groupby and pivoting by date and event and ad_id
ads_data[ads_data.date == '2019-04-05'] \
.groupby('ad_id') \
.agg({'time': 'count'}) \
.sort_values('time', ascending=False) \
.head()
specifiying time and aggregating and sorting out the value time
.groupby('ad_id') \
.agg({'time': 'count'}) \
.sort_values('time', ascending=False) \
.head()
specifiying time and aggregating and sorting out the value time
ads_data.query('ad_id == @ad_id').head(1) with query you will find out the this one
.pivot(index='ad_id', columns='event', values='time').reset_index() this with reset_index helps to start index by again
ads_data_by_ad.assign(ctr = ads_data_by_ad.click / ads_data_by_ad.view,
ctr_per = 100 * ads_data_by_ad.click / ads_data_by_ad.view)
when there is 2 variables and you are assinging that in one table new variables aare in here
ctr_per = 100 * ads_data_by_ad.click / ads_data_by_ad.view)
when there is 2 variables and you are assinging that in one table new variables aare in here
ads_data_by_ad.query('view == 0').ad_id finding out the missing column
ads_data[ads_data.ad_id.isin(ads_ids_bug)] finding out the wrong things
ads_data[ads_data.ad_id == 16548].sort_values('time') sorting out with time
okay download the dataset work with unproper columns like convert them or with usecols you can filter out in the begining then work with isnull values then find out what we need and use groupby query agg and use why not debugs then quantiles after finding out the problem issue we will look at the only data that we need and find out the root cause
df[df['workingday'] == 0] filtering where we need the workingday filtered
df[
(df['workingday'] == 1) & (df['season'] == 1)
]
working with two filters
and using ~
(df['workingday'] == 1) & (df['season'] == 1)
]
working with two filters
and using ~
df[df['windspeed'].isna()] specifically finding out by column that there is a null value