从数据框架创建矩阵

发布于 2025-02-03 05:53:23 字数 174 浏览 0 评论 0 原文

我有一个带有几列的数据框,包括部门和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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

轻许诺言 2025-02-10 05:53:23

您可以使用基于整数的索引从数据框中获取值,并使用方法。这似乎可以做您需要的事情。

例如,如果 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, then df.iloc[0, 2] will give you the value at the first row and third column.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文