Python Forum

Full Version: Need help on group by function.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
(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.
Hello!

Try to post a pseudo code. I don't know R either