0
$\begingroup$

I have the following data set where the column "kind" can be V(view) or A(apply), how can I do the following things given a particular job id how many applicant Apply (A) to that particular job and how many applicant View(V) the particular job? So I want a column with job and two columns with One labled view other labelled A for the job type. I am working in Jupyter notebook python, pandas, if someone can initiate or show me similar code will be really helpful


event_datetime  resume_id   job_id  event_platform  kind    Time    Date
0   2021-05-01 08:42:05 158655  38820886    IOS_APP V   08:42:05    2021-05-01
1   2021-05-01 08:42:05 158655  38901970    IOS_APP V   08:42:05    2021-05-01
2   2021-05-01 08:42:05 158655  38919645    IOS_APP V   08:42:05    2021-05-01
3   2021-05-01 08:42:05 158655  38928402    IOS_APP V   08:42:05    2021-05-01
4   2021-05-01 08:42:05 158655  38847632    IOS_APP V   08:42:05    2021-05-01
5   2021-05-01 08:42:05 158655  38892709    IOS_APP V   08:42:05    2021-05-01
6   2021-05-01 08:42:05 158655  38987246    IOS_APP V   08:42:05    2021-05-01
7   2021-05-01 08:42:05 158655  38983852    IOS_APP V   08:42:05    2021-05-01
8   2021-05-01 08:42:05 158655  38970661    IOS_APP V   08:42:05    2021-05-01
9   2021-05-01 08:42:05 158655  38982545    IOS_APP V   08:42:05    2021-05-01
10  2021-05-01 08:42:05 158655  38815059    IOS_APP V   08:42:05    2021-05-01
11  2021-05-01 08:42:05 158655  38939806    IOS_APP V   08:42:05    2021-05-01
12  2021-05-01 08:42:05 158655  38957174    IOS_APP V   08:42:05    2021-05-01
13  2021-05-01 08:42:05 158655  39002021    IOS_APP V   08:42:05    2021-05-01
14  2021-05-01 08:42:05 158655  38396095    IOS_APP V   08:42:05    2021-05-01
15  2021-05-01 08:42:05 158655  38969243    IOS_APP V   08:42:05    2021-05-01
16  2021-05-01 08:42:05 158655  38880479    IOS_APP V   08:42:05    2021-05-01
17  2021-05-01 08:42:05 158655  38973440    IOS_APP V   08:42:05    2021-05-01
18  2021-05-01 08:42:05 158655  38908077    IOS_APP V   08:42:05    2021-05-01
19  2021-05-01 08:42:05 158655  38899054    IOS_APP V   08:42:05    2021-05-01
$\endgroup$

1 Answer 1

0
$\begingroup$

This should be possible by first aggregating the data to get the number of records for each job identifier and kind of action and then pivoting the rows to the columns:

(
    df
    .groupby(["job_id", "kind"])
    .count()["resume_id"]
    .reset_index()
    .pivot(index="job_id", columns="kind")
)
$\endgroup$
3
  • $\begingroup$ Can we just have job_id and the other two columns A and V? $\endgroup$
    – GGT
    Dec 23, 2021 at 10:51
  • $\begingroup$ The colums return is MultiIndex([('event_datetime', 'A'), ('event_datetime', 'V'), ( 'resume_id', 'A'), ( 'resume_id', 'V'), ('event_platform', 'A'), ('event_platform', 'V'), ( 'Time', 'A'), ( 'Time', 'V'), ( 'Date', 'A'), ( 'Date', 'V')], names=[None, 'kind']) $\endgroup$
    – GGT
    Dec 23, 2021 at 11:08
  • $\begingroup$ If you just want the two columns you should be able to get this by simply selecting a column after using count. $\endgroup$
    – Oxbowerce
    Dec 23, 2021 at 11:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.