二维np.数字化

2024-10-01 17:41:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我有二维数据,我有一堆用scipy.stats.binned_statistic_2d生成的二维容器。对于每个数据点,我需要它所占的存储单元的索引。这正是np.digitize的目的,但据我所知,它只处理一维数据。Thisstackexchange似乎有一个答案,但这是完全概括到n维的。有没有一个更直接的二维解决方案?在


Tags: 数据答案目的statsnpscipy解决方案statistic
1条回答
网友
1楼 · 发布于 2024-10-01 17:41:21

您已经可以从^{}的第四个返回变量中获取每个观测值的bin索引:

Returns:  
  statistic : (nx, ny) ndarray
      The values of the selected statistic in each two-dimensional bin
  xedges : (nx + 1) ndarray
      The bin edges along the first dimension.
  yedges : (ny + 1) ndarray
      The bin edges along the second dimension.
  binnumber : 1-D ndarray of ints
      This assigns to each observation an integer that represents the bin
      in which this observation falls. Array has the same length as values.

相关问题 更多 >

    热门问题