[英]If I have two matrices and I want to divide the data and want to keep the same consistency (the Nones stay where they are) in Python?
Data is below:数据如下:
I want to get:我想得到:
Salaries / Games
However, get: TypeError Traceback (most recent call last) in ----> 1 SalaryGames = Salary / Games但是,在----> 1 SalaryGames = Salary / Games 中得到:TypeError Traceback (last last call last)
TypeError: unsupported operand type(s) for /: 'NoneType' and 'NoneType' TypeError:不支持的操作数类型/:“NoneType”和“NoneType”
#Salaries
KobeBryant_Salary = [15946875,17718750,19490625,21262500,23034375,24806250,25244493,27849149,None,None]
JoeJohnson_Salary = [12000000,12744189,13488377,14232567,14976754,16324500,18038573,19752645,21466718,23180790]
LeBronJames_Salary = [4621800,5828090,13041250,14410581,15779912,14500000,16022500,17545000,19067500,20644400]
CarmeloAnthony_Salary = [3713640,4694041,13041250,14410581,15779912,17149243,18518574,19450000,22407474,22458000]
DwightHoward_Salary = [4493160,4806720,6061274,13758000,15202590,16647180,18091770,19536360,20513178,21436271]
ChrisBosh_Salary = [3348000,4235220,12455000,14410581,15779912,14500000,16022500,17545000,19067500,20644400]
ChrisPaul_Salary = [3144240,3380160,3615960,4574189,13520500,14940153,16359805,17779458,18668431,20068563]
KevinDurant_Salary = [0,0,4171200,4484040,4796880,6053663,15506632,16669630,17832627,18995624]
DerrickRose_Salary = [0,0,0,4822800,5184480,5546160,None,None,None,None]
DwayneWade_Salary = [3031920,3841443,13041250,14410581,15779912,14200000,15691000,17182000,18673000,15000000]
#Matrix
Salary = np.array([KobeBryant_Salary, JoeJohnson_Salary, LeBronJames_Salary, CarmeloAnthony_Salary, DwightHoward_Salary, ChrisBosh_Salary, ChrisPaul_Salary, KevinDurant_Salary, DerrickRose_Salary, DwayneWade_Salary])
#Games
KobeBryant_G = [80,77,82,82,73,82,58,78,None,None]
JoeJohnson_G = [82,57,82,79,76,72,60,72,79,80]
LeBronJames_G = [79,78,75,81,76,79,62,76,77,69]
CarmeloAnthony_G = [80,65,77,66,69,77,55,67,77,40]
DwightHoward_G = [82,82,82,79,82,78,54,76,71,41]
ChrisBosh_G = [70,69,67,77,70,77,57,74,79,44]
ChrisPaul_G = [78,64,80,78,45,80,60,70,62,82]
KevinDurant_G = [35,35,80,74,82,78,66,81,81,27]
DerrickRose_G = [40,40,40,81,78,81,None,None,None,None]
DwayneWade_G = [75,51,51,79,77,76,49,69,54,62]
#Matrix
Games = np.array([KobeBryant_G, JoeJohnson_G, LeBronJames_G, CarmeloAnthony_G, DwightHoward_G, ChrisBosh_G, ChrisPaul_G, KevinDurant_G, DerrickRose_G, DwayneWade_G])
Change all None
to np.nan
.将所有
None
更改为np.nan
。 That should do the trick.这应该够了吧。
https://colab.research.google.com/drive/1JXdLQvZwkU7Y2wrSM7sLbVlFxBdSHVEq?usp=sharing&fbclid=IwAR1SUEl4_h7Wa8exAlkCUNbOVnDBj3_z73PoqGhIgmsixKDSyPcVyOW04O8 https://colab.research.google.com/drive/1JXdLQvZwkU7Y2wrSM7sLbVlFxBdSHVEq?usp=sharing&fbclid=IwAR1SUEl4_h7Wa8exAlkCUNbOVnDBj3_z73PoqGhIgmsixKDSycP
See the graphs at the end.见最后的图表。 There's too many injuries and when a number goes from 1000 to 0 it makes the lines get skewed.
受伤太多了,当一个数字从 1000 变为 0 时,它会使线条歪斜。 Thanks to all the answers!
感谢所有的答案!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.