我有一个带有几列的数据框,包括部门和ICA。我需要创建一个矩阵,其中行是部门,列是ICA值(它们范围为不可接受的良好范围)。
因此,位置R,C将是一个数字,显示每个部门记录了多少ICA观察。
例如,如果Amazonas是第1行,并且可以接受的是第3列,则位置(1,3)将是亚马逊群岛可接受的观测值。
谢谢!
I have a dataframe with several columns, including Department and ICA. I need to create a matrix where the rows are the departments, and the columns are ICA values (they range from bad-acceptable-good).
So position r,c would be a number that shows how many observations of ICA were recorded for each department.
For example, if Amazonas is row 1 and Acceptable is column 3, position (1,3) would be the number of acceptable observations for Amazonas.
Thanks!
发布评论
评论(1)
您可以使用基于整数的索引从数据框中获取值,并使用方法。这似乎可以做您需要的事情。
例如,如果
df
是您的数据框架,则df.iloc [0,2]
将为您提供第一行和第三列的值。You can get values from your DataFrame using integer-based indexing with the DataFrame.iloc method. This seems to do what you need.
For example, if
df
is your DataFrame, thendf.iloc[0, 2]
will give you the value at the first row and third column.