Python Forum
Need help on group by function.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help on group by function.
#1
Hi Guru's,

i am beginner of Python. i am struck with converting "R" script(below) into Python.

total_sales = sum(transactions['PureSales'])

job_roles <- transactions %>%
group_by(JobRole,job_classification) %>%
summarise(
     order_lines = n(),
     prop_order_lines = order_lines/nrow(transactions),
    orders = n_distinct(OrderNumber),
    sales = sum(PureSales),
    prop_sales = sum(PureSales)/total_sales
  ) %>%
ungroup
Could you please help, i can i write same code in python?


thanks a bunch in advance.

Sree.
Reply
#2
(Mar-06-2018, 06:11 PM)Sree Wrote: %>%
Without knowing R, that looks like nonsense. Have you started to rewrite it? If you post your python code, what your output it and what you want your output to be, we can help get from one to the other.

But without code, or input->output, the only way someone can help is if they know R.
Reply
#3
Hello!

Try to post a pseudo code. I don't know R either
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020