Coding skills here for learning
6 subscribers
266 photos
3 files
10 links
Download Telegram
df3_g = df3 \
.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_total_Revenue = df3 \
.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
pd.to_datetime(ads_data.date) date only
ads_data.groupby('date') \
.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
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
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
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
columns[1:5] finding out the spliting column
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[df['windspeed'].isna()] specifically finding out by column that there is a null value
df['workingday'].isna().any() assuring that
df[df['season'].isin([1, 3, 4])]