dt=df['dt']
first=df['first']
x=pd.value_counts(pd.to_datetime(df.dt.sum()).strftime('%Y-%m'))
y=pd.value_counts(pd.to_datetime(first.sum()).strftime('%Y-%m'))
x y
2015-01 111 2015-01 654
2015-03 1231 2015-03 315
2015-05 123 2015-05 464
2015-02 456 2015-02 654
. .
. .
x和y是具有數據這樣熊貓想之間兩種不同的數據使用DIC
即)2015-01 =(111分之654)* 100
我wnat到計算百分比計算像同年個月的X,Y(X/Y)×100
y x
((2015-01+2015-02)/2015-02)*100
((2015-01+2015-02+2015-03)/2015-03)*100
2015-02=(654+654/456)*100
2015-03=(654+654+315/1231)*100
like this
I want to put this x and y in dictionary
date is key and number is value
ie) dict={2105-01:111,2015-03:1231......}
'(x/y)* 100'不起作用? – jezrael
'2015-01 =(654/111)* 100'是否正確? – jezrael
您可以添加'2015-02 =(654 + 654/456)* 100 2015-03 =(654 + 654 + 315/1231)* 100'的輸出嗎? – jezrael