Tôi có một khung dữ liệu mà tôi đã tạo bởi một nhóm:
hmdf = pd.DataFrame[hm01]
new_hm01 = hmdf[['FinancialYear','Month','FirstReceivedDate']]
hm05 = new_hm01.pivot_table[index=['FinancialYear','Month'], aggfunc='count']
vals1 = ['April ', 'May ', 'June ', 'July ', 'August ', 'September', 'October ', 'November ', 'December ', 'January ', 'February ', 'March ']
df_hm = new_hm01.groupby[['Month', 'FinancialYear']].size[].unstack[fill_value=0].rename[columns=lambda x: '{}'.format[x]]
df_hml = df_hm.reindex[vals1]
DF trông như thế này:
FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
Tên cột là từ các biến [threeYr,twoYr,oneYr,Yr]
và tôi muốn chuyển đổi DataFrame để các số là tỷ lệ phần trăm của tổng số cho mỗi cột, nhưng tôi không thể làm cho nó hoạt động.
Đây là những gì tôi muốn:
FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 9% 6% 6% 24%
May 7% 7% 6% 29%
June 5% 10% 6% 24%
July 6% 10% 5% 24%
August 9% 8% 10% 0%
September 9% 6% 12% 0%
October 9% 10% 8% 0%
November 10% 8% 9% 0%
December 9% 11% 7% 0%
January 9% 8% 10% 0%
February 9% 7% 11% 0%
March 9% 8% 10% 0%
Bất cứ ai có thể giúp tôi làm điều này?
EDIT: Tôi đã thử phản hồi được tìm thấy tại liên kết này: Pandas chuyển đổi cột thành tỷ lệ phần trăm tổng số ..... Tôi không thể làm việc đó cho DataFrame của mình + nó không giải thích tốt [với tôi] làm thế nào để làm cho nó hoạt động bất kỳ df. Phản hồi từ John Galt tôi tin là tốt hơn phản hồi đó [ý kiến của tôi].
Các
Ví dụ 2: & nbsp;
import
pandas as pd
FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
0____11 FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
21| INPUT: 2| 3| col_1 col_2 4| 0 43 120 5| 1 25 3 6| 2 67 19 7| 3 86 34 8| 9| df['total'] = df['col_1'] + df['col_2'] 10| df = df.pipe[lambda x: x.div[x['total'], axis='index']].applymap['{:.0%}'.format] 11| 12| OUPUT: 13| 14| col_1 col_2 total 15| 0 26% 74% 100% 16| 1 89% 11% 100% 17| 2 78% 22% 100% 18| 3 72% 28% 100%
Các
‘
Các
Ví dụ 2: & nbsp;
Các
Ví dụ 2: & nbsp;
Các Percentage is calculated by the mathematical formula of dividing the value by the sum of all the values and then multiplying the sum by 100. This is also applicable in Pandas Dataframes. Here, the pre-defined sum[] method of pandas series is used to compute the sum of all the values of a column.
Cú pháp: series.sum []Series.sum[]
Trả về: Trả về tổng của các giá trị. Returns the sum of the values.
Formula:
df[percent] = [df['column_name'] / df['column_name'].sum[]] * 100
Ví dụ 1: & nbsp;
Python3
import
pandas as pd
import
numpy as np
FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
0____11 FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
2FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
3FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
4FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
5FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
6FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
7FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
8FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
7FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 9% 6% 6% 24%
May 7% 7% 6% 29%
June 5% 10% 6% 24%
July 6% 10% 5% 24%
August 9% 8% 10% 0%
September 9% 6% 12% 0%
October 9% 10% 8% 0%
November 10% 8% 9% 0%
December 9% 11% 7% 0%
January 9% 8% 10% 0%
February 9% 7% 11% 0%
March 9% 8% 10% 0%
0FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 9% 6% 6% 24%
May 7% 7% 6% 29%
June 5% 10% 6% 24%
July 6% 10% 5% 24%
August 9% 8% 10% 0%
September 9% 6% 12% 0%
October 9% 10% 8% 0%
November 10% 8% 9% 0%
December 9% 11% 7% 0%
January 9% 8% 10% 0%
February 9% 7% 11% 0%
March 9% 8% 10% 0%
1FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 9% 6% 6% 24%
May 7% 7% 6% 29%
June 5% 10% 6% 24%
July 6% 10% 5% 24%
August 9% 8% 10% 0%
September 9% 6% 12% 0%
October 9% 10% 8% 0%
November 10% 8% 9% 0%
December 9% 11% 7% 0%
January 9% 8% 10% 0%
February 9% 7% 11% 0%
March 9% 8% 10% 0%
2FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 9% 6% 6% 24%
May 7% 7% 6% 29%
June 5% 10% 6% 24%
July 6% 10% 5% 24%
August 9% 8% 10% 0%
September 9% 6% 12% 0%
October 9% 10% 8% 0%
November 10% 8% 9% 0%
December 9% 11% 7% 0%
January 9% 8% 10% 0%
February 9% 7% 11% 0%
March 9% 8% 10% 0%
3FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
7FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 9% 6% 6% 24%
May 7% 7% 6% 29%
June 5% 10% 6% 24%
July 6% 10% 5% 24%
August 9% 8% 10% 0%
September 9% 6% 12% 0%
October 9% 10% 8% 0%
November 10% 8% 9% 0%
December 9% 11% 7% 0%
January 9% 8% 10% 0%
February 9% 7% 11% 0%
March 9% 8% 10% 0%
5FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
7FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 9% 6% 6% 24%
May 7% 7% 6% 29%
June 5% 10% 6% 24%
July 6% 10% 5% 24%
August 9% 8% 10% 0%
September 9% 6% 12% 0%
October 9% 10% 8% 0%
November 10% 8% 9% 0%
December 9% 11% 7% 0%
January 9% 8% 10% 0%
February 9% 7% 11% 0%
March 9% 8% 10% 0%
7FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 9% 6% 6% 24%
May 7% 7% 6% 29%
June 5% 10% 6% 24%
July 6% 10% 5% 24%
August 9% 8% 10% 0%
September 9% 6% 12% 0%
October 9% 10% 8% 0%
November 10% 8% 9% 0%
December 9% 11% 7% 0%
January 9% 8% 10% 0%
February 9% 7% 11% 0%
March 9% 8% 10% 0%
1FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 9% 6% 6% 24%
May 7% 7% 6% 29%
June 5% 10% 6% 24%
July 6% 10% 5% 24%
August 9% 8% 10% 0%
September 9% 6% 12% 0%
October 9% 10% 8% 0%
November 10% 8% 9% 0%
December 9% 11% 7% 0%
January 9% 8% 10% 0%
February 9% 7% 11% 0%
March 9% 8% 10% 0%
21| INPUT: 2| 3| col_1 col_2 4| 0 43 120 5| 1 25 3 6| 2 67 19 7| 3 86 34 8| 9| df['total'] = df['col_1'] + df['col_2'] 10| df = df.pipe[lambda x: x.div[x['total'], axis='index']].applymap['{:.0%}'.format] 11| 12| OUPUT: 13| 14| col_1 col_2 total 15| 0 26% 74% 100% 16| 1 89% 11% 100% 17| 2 78% 22% 100% 18| 3 72% 28% 100%0
1| INPUT: 2| 3| col_1 col_2 4| 0 43 120 5| 1 25 3 6| 2 67 19 7| 3 86 34 8| 9| df['total'] = df['col_1'] + df['col_2'] 10| df = df.pipe[lambda x: x.div[x['total'], axis='index']].applymap['{:.0%}'.format] 11| 12| OUPUT: 13| 14| col_1 col_2 total 15| 0 26% 74% 100% 16| 1 89% 11% 100% 17| 2 78% 22% 100% 18| 3 72% 28% 100%1
FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
31| INPUT: 2| 3| col_1 col_2 4| 0 43 120 5| 1 25 3 6| 2 67 19 7| 3 86 34 8| 9| df['total'] = df['col_1'] + df['col_2'] 10| df = df.pipe[lambda x: x.div[x['total'], axis='index']].applymap['{:.0%}'.format] 11| 12| OUPUT: 13| 14| col_1 col_2 total 15| 0 26% 74% 100% 16| 1 89% 11% 100% 17| 2 78% 22% 100% 18| 3 72% 28% 100%3
FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
51| INPUT: 2| 3| col_1 col_2 4| 0 43 120 5| 1 25 3 6| 2 67 19 7| 3 86 34 8| 9| df['total'] = df['col_1'] + df['col_2'] 10| df = df.pipe[lambda x: x.div[x['total'], axis='index']].applymap['{:.0%}'.format] 11| 12| OUPUT: 13| 14| col_1 col_2 total 15| 0 26% 74% 100% 16| 1 89% 11% 100% 17| 2 78% 22% 100% 18| 3 72% 28% 100%5
FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
71| INPUT: 2| 3| col_1 col_2 4| 0 43 120 5| 1 25 3 6| 2 67 19 7| 3 86 34 8| 9| df['total'] = df['col_1'] + df['col_2'] 10| df = df.pipe[lambda x: x.div[x['total'], axis='index']].applymap['{:.0%}'.format] 11| 12| OUPUT: 13| 14| col_1 col_2 total 15| 0 26% 74% 100% 16| 1 89% 11% 100% 17| 2 78% 22% 100% 18| 3 72% 28% 100%7
FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
71| INPUT: 2| 3| col_1 col_2 4| 0 43 120 5| 1 25 3 6| 2 67 19 7| 3 86 34 8| 9| df['total'] = df['col_1'] + df['col_2'] 10| df = df.pipe[lambda x: x.div[x['total'], axis='index']].applymap['{:.0%}'.format] 11| 12| OUPUT: 13| 14| col_1 col_2 total 15| 0 26% 74% 100% 16| 1 89% 11% 100% 17| 2 78% 22% 100% 18| 3 72% 28% 100%9
FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 9% 6% 6% 24%
May 7% 7% 6% 29%
June 5% 10% 6% 24%
July 6% 10% 5% 24%
August 9% 8% 10% 0%
September 9% 6% 12% 0%
October 9% 10% 8% 0%
November 10% 8% 9% 0%
December 9% 11% 7% 0%
January 9% 8% 10% 0%
February 9% 7% 11% 0%
March 9% 8% 10% 0%
1df[percent] = [df['column_name'] / df['column_name'].sum[]] * 1001
df[percent] = [df['column_name'] / df['column_name'].sum[]] * 1002
FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
7df[percent] = [df['column_name'] / df['column_name'].sum[]] * 1004
FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
7df[percent] = [df['column_name'] / df['column_name'].sum[]] * 1006
FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 9% 6% 6% 24%
May 7% 7% 6% 29%
June 5% 10% 6% 24%
July 6% 10% 5% 24%
August 9% 8% 10% 0%
September 9% 6% 12% 0%
October 9% 10% 8% 0%
November 10% 8% 9% 0%
December 9% 11% 7% 0%
January 9% 8% 10% 0%
February 9% 7% 11% 0%
March 9% 8% 10% 0%
1df[percent] = [df['column_name'] / df['column_name'].sum[]] * 1001
df[percent] = [df['column_name'] / df['column_name'].sum[]] * 1009
[threeYr,twoYr,oneYr,Yr]
0FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
0____11 [threeYr,twoYr,oneYr,Yr]
3df[percent] = [df['column_name'] / df['column_name'].sum[]] * 1001
[threeYr,twoYr,oneYr,Yr]
5FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
1 [threeYr,twoYr,oneYr,Yr]
7FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
4FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 9% 6% 6% 24%
May 7% 7% 6% 29%
June 5% 10% 6% 24%
July 6% 10% 5% 24%
August 9% 8% 10% 0%
September 9% 6% 12% 0%
October 9% 10% 8% 0%
November 10% 8% 9% 0%
December 9% 11% 7% 0%
January 9% 8% 10% 0%
February 9% 7% 11% 0%
March 9% 8% 10% 0%
1import
0
1| INPUT: 2| 3| col_1 col_2 4| 0 43 120 5| 1 25 3 6| 2 67 19 7| 3 86 34 8| 9| df['total'] = df['col_1'] + df['col_2'] 10| df = df.pipe[lambda x: x.div[x['total'], axis='index']].applymap['{:.0%}'.format] 11| 12| OUPUT: 13| 14| col_1 col_2 total 15| 0 26% 74% 100% 16| 1 89% 11% 100% 17| 2 78% 22% 100% 18| 3 72% 28% 100%3
import
2‘
Các
pandas as pd
9
Output:
Ví dụ 2: & nbsp;
Python3
import
pandas as pd
FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
0____11 FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
2FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
3FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
4FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
5FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
6FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
7FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
8FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
7FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 9% 6% 6% 24%
May 7% 7% 6% 29%
June 5% 10% 6% 24%
July 6% 10% 5% 24%
August 9% 8% 10% 0%
September 9% 6% 12% 0%
October 9% 10% 8% 0%
November 10% 8% 9% 0%
December 9% 11% 7% 0%
January 9% 8% 10% 0%
February 9% 7% 11% 0%
March 9% 8% 10% 0%
0FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 9% 6% 6% 24%
May 7% 7% 6% 29%
June 5% 10% 6% 24%
July 6% 10% 5% 24%
August 9% 8% 10% 0%
September 9% 6% 12% 0%
October 9% 10% 8% 0%
November 10% 8% 9% 0%
December 9% 11% 7% 0%
January 9% 8% 10% 0%
February 9% 7% 11% 0%
March 9% 8% 10% 0%
1FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 9% 6% 6% 24%
May 7% 7% 6% 29%
June 5% 10% 6% 24%
July 6% 10% 5% 24%
August 9% 8% 10% 0%
September 9% 6% 12% 0%
October 9% 10% 8% 0%
November 10% 8% 9% 0%
December 9% 11% 7% 0%
January 9% 8% 10% 0%
February 9% 7% 11% 0%
March 9% 8% 10% 0%
2FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 9% 6% 6% 24%
May 7% 7% 6% 29%
June 5% 10% 6% 24%
July 6% 10% 5% 24%
August 9% 8% 10% 0%
September 9% 6% 12% 0%
October 9% 10% 8% 0%
November 10% 8% 9% 0%
December 9% 11% 7% 0%
January 9% 8% 10% 0%
February 9% 7% 11% 0%
March 9% 8% 10% 0%
3FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
7FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 9% 6% 6% 24%
May 7% 7% 6% 29%
June 5% 10% 6% 24%
July 6% 10% 5% 24%
August 9% 8% 10% 0%
September 9% 6% 12% 0%
October 9% 10% 8% 0%
November 10% 8% 9% 0%
December 9% 11% 7% 0%
January 9% 8% 10% 0%
February 9% 7% 11% 0%
March 9% 8% 10% 0%
5FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
7FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 9% 6% 6% 24%
May 7% 7% 6% 29%
June 5% 10% 6% 24%
July 6% 10% 5% 24%
August 9% 8% 10% 0%
September 9% 6% 12% 0%
October 9% 10% 8% 0%
November 10% 8% 9% 0%
December 9% 11% 7% 0%
January 9% 8% 10% 0%
February 9% 7% 11% 0%
March 9% 8% 10% 0%
7FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 9% 6% 6% 24%
May 7% 7% 6% 29%
June 5% 10% 6% 24%
July 6% 10% 5% 24%
August 9% 8% 10% 0%
September 9% 6% 12% 0%
October 9% 10% 8% 0%
November 10% 8% 9% 0%
December 9% 11% 7% 0%
January 9% 8% 10% 0%
February 9% 7% 11% 0%
March 9% 8% 10% 0%
1FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 9% 6% 6% 24%
May 7% 7% 6% 29%
June 5% 10% 6% 24%
July 6% 10% 5% 24%
August 9% 8% 10% 0%
September 9% 6% 12% 0%
October 9% 10% 8% 0%
November 10% 8% 9% 0%
December 9% 11% 7% 0%
January 9% 8% 10% 0%
February 9% 7% 11% 0%
March 9% 8% 10% 0%
21| INPUT: 2| 3| col_1 col_2 4| 0 43 120 5| 1 25 3 6| 2 67 19 7| 3 86 34 8| 9| df['total'] = df['col_1'] + df['col_2'] 10| df = df.pipe[lambda x: x.div[x['total'], axis='index']].applymap['{:.0%}'.format] 11| 12| OUPUT: 13| 14| col_1 col_2 total 15| 0 26% 74% 100% 16| 1 89% 11% 100% 17| 2 78% 22% 100% 18| 3 72% 28% 100%0
1| INPUT: 2| 3| col_1 col_2 4| 0 43 120 5| 1 25 3 6| 2 67 19 7| 3 86 34 8| 9| df['total'] = df['col_1'] + df['col_2'] 10| df = df.pipe[lambda x: x.div[x['total'], axis='index']].applymap['{:.0%}'.format] 11| 12| OUPUT: 13| 14| col_1 col_2 total 15| 0 26% 74% 100% 16| 1 89% 11% 100% 17| 2 78% 22% 100% 18| 3 72% 28% 100%1
FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
041| INPUT: 2| 3| col_1 col_2 4| 0 43 120 5| 1 25 3 6| 2 67 19 7| 3 86 34 8| 9| df['total'] = df['col_1'] + df['col_2'] 10| df = df.pipe[lambda x: x.div[x['total'], axis='index']].applymap['{:.0%}'.format] 11| 12| OUPUT: 13| 14| col_1 col_2 total 15| 0 26% 74% 100% 16| 1 89% 11% 100% 17| 2 78% 22% 100% 18| 3 72% 28% 100%3
FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
51| INPUT: 2| 3| col_1 col_2 4| 0 43 120 5| 1 25 3 6| 2 67 19 7| 3 86 34 8| 9| df['total'] = df['col_1'] + df['col_2'] 10| df = df.pipe[lambda x: x.div[x['total'], axis='index']].applymap['{:.0%}'.format] 11| 12| OUPUT: 13| 14| col_1 col_2 total 15| 0 26% 74% 100% 16| 1 89% 11% 100% 17| 2 78% 22% 100% 18| 3 72% 28% 100%5
FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
71| INPUT: 2| 3| col_1 col_2 4| 0 43 120 5| 1 25 3 6| 2 67 19 7| 3 86 34 8| 9| df['total'] = df['col_1'] + df['col_2'] 10| df = df.pipe[lambda x: x.div[x['total'], axis='index']].applymap['{:.0%}'.format] 11| 12| OUPUT: 13| 14| col_1 col_2 total 15| 0 26% 74% 100% 16| 1 89% 11% 100% 17| 2 78% 22% 100% 18| 3 72% 28% 100%7
FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
71| INPUT: 2| 3| col_1 col_2 4| 0 43 120 5| 1 25 3 6| 2 67 19 7| 3 86 34 8| 9| df['total'] = df['col_1'] + df['col_2'] 10| df = df.pipe[lambda x: x.div[x['total'], axis='index']].applymap['{:.0%}'.format] 11| 12| OUPUT: 13| 14| col_1 col_2 total 15| 0 26% 74% 100% 16| 1 89% 11% 100% 17| 2 78% 22% 100% 18| 3 72% 28% 100%9
FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 9% 6% 6% 24%
May 7% 7% 6% 29%
June 5% 10% 6% 24%
July 6% 10% 5% 24%
August 9% 8% 10% 0%
September 9% 6% 12% 0%
October 9% 10% 8% 0%
November 10% 8% 9% 0%
December 9% 11% 7% 0%
January 9% 8% 10% 0%
February 9% 7% 11% 0%
March 9% 8% 10% 0%
1FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
13df[percent] = [df['column_name'] / df['column_name'].sum[]] * 1002
FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
7df[percent] = [df['column_name'] / df['column_name'].sum[]] * 1004
FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
7df[percent] = [df['column_name'] / df['column_name'].sum[]] * 1006
FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 9% 6% 6% 24%
May 7% 7% 6% 29%
June 5% 10% 6% 24%
July 6% 10% 5% 24%
August 9% 8% 10% 0%
September 9% 6% 12% 0%
October 9% 10% 8% 0%
November 10% 8% 9% 0%
December 9% 11% 7% 0%
January 9% 8% 10% 0%
February 9% 7% 11% 0%
March 9% 8% 10% 0%
1FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
13df[percent] = [df['column_name'] / df['column_name'].sum[]] * 1009
1| INPUT: 2| 3| col_1 col_2 4| 0 43 120 5| 1 25 3 6| 2 67 19 7| 3 86 34 8| 9| df['total'] = df['col_1'] + df['col_2'] 10| df = df.pipe[lambda x: x.div[x['total'], axis='index']].applymap['{:.0%}'.format] 11| 12| OUPUT: 13| 14| col_1 col_2 total 15| 0 26% 74% 100% 16| 1 89% 11% 100% 17| 2 78% 22% 100% 18| 3 72% 28% 100%1
FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
0____11 [threeYr,twoYr,oneYr,Yr]
3FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
13FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
33FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
7FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
35FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
7FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
37FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 9% 6% 6% 24%
May 7% 7% 6% 29%
June 5% 10% 6% 24%
July 6% 10% 5% 24%
August 9% 8% 10% 0%
September 9% 6% 12% 0%
October 9% 10% 8% 0%
November 10% 8% 9% 0%
December 9% 11% 7% 0%
January 9% 8% 10% 0%
February 9% 7% 11% 0%
March 9% 8% 10% 0%
1FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
13FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
40FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
41FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
42FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
0____11 [threeYr,twoYr,oneYr,Yr]
3df[percent] = [df['column_name'] / df['column_name'].sum[]] * 1001
[threeYr,twoYr,oneYr,Yr]
5FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
1 [threeYr,twoYr,oneYr,Yr]
7FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
4FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 9% 6% 6% 24%
May 7% 7% 6% 29%
June 5% 10% 6% 24%
July 6% 10% 5% 24%
August 9% 8% 10% 0%
September 9% 6% 12% 0%
October 9% 10% 8% 0%
November 10% 8% 9% 0%
December 9% 11% 7% 0%
January 9% 8% 10% 0%
February 9% 7% 11% 0%
March 9% 8% 10% 0%
1df[percent] = [df['column_name'] / df['column_name'].sum[]] * 1001
1| INPUT: 2| 3| col_1 col_2 4| 0 43 120 5| 1 25 3 6| 2 67 19 7| 3 86 34 8| 9| df['total'] = df['col_1'] + df['col_2'] 10| df = df.pipe[lambda x: x.div[x['total'], axis='index']].applymap['{:.0%}'.format] 11| 12| OUPUT: 13| 14| col_1 col_2 total 15| 0 26% 74% 100% 16| 1 89% 11% 100% 17| 2 78% 22% 100% 18| 3 72% 28% 100%3
FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 9% 6% 6% 24%
May 7% 7% 6% 29%
June 5% 10% 6% 24%
July 6% 10% 5% 24%
August 9% 8% 10% 0%
September 9% 6% 12% 0%
October 9% 10% 8% 0%
November 10% 8% 9% 0%
December 9% 11% 7% 0%
January 9% 8% 10% 0%
February 9% 7% 11% 0%
March 9% 8% 10% 0%
1FinancialYear 2014/2015 2015/2016 2016/2017 2017/2018
Month
April 34 24 22 20
May 29 26 21 25
June 19 39 22 20
July 23 39 18 20
August 36 30 34 0
September 35 23 41 0
October 36 37 27 0
November 38 31 30 0
December 36 41 23 0
January 34 30 35 0
February 37 26 37 0
March 36 31 33 0
24import
2import
0
1| INPUT: 2| 3| col_1 col_2 4| 0 43 120 5| 1 25 3 6| 2 67 19 7| 3 86 34 8| 9| df['total'] = df['col_1'] + df['col_2'] 10| df = df.pipe[lambda x: x.div[x['total'], axis='index']].applymap['{:.0%}'.format] 11| 12| OUPUT: 13| 14| col_1 col_2 total 15| 0 26% 74% 100% 16| 1 89% 11% 100% 17| 2 78% 22% 100% 18| 3 72% 28% 100%3
import
2‘
pandas as pd
9
Output: