小编Nov*_*vus的帖子

如何从多索引数据框中返回多个级别/组的值?

这是我的多索引数据框:

# Index Levels
outside = ['G1','G1','G1','G2','G2','G2']
inside = [1,2,3,1,2,3]
hier_index = list(zip(outside,inside))
hier_index = pd.MultiIndex.from_tuples(hier_index)
df = pd.DataFrame(np.random.randn(6,2),index=hier_index,columns=['A','B'])
df.index.names = ['Group','Num']
df
Run Code Online (Sandbox Code Playgroud)

数据框如下所示:

                  A           B
Group   Num     
G1      1     0.147027  -0.479448
        2     0.558769   1.024810
        3    -0.925874   1.862864
G2      1    -1.133817   0.610478
        2     0.386030   2.084019
        3    -0.376519   0.230336
Run Code Online (Sandbox Code Playgroud)

我想要实现的是返回Group G1and G2, Num 1and 中的值,3如下所示:

G1     1     0.147027   -0.479448
       3    -0.925874    1.862864
G2     1    -1.133817    0.610478
       3    -0.376519    0.230336
Run Code Online (Sandbox Code Playgroud)

我试过了

df.loc[['G1','G2']].loc[[1,3]]
Run Code Online (Sandbox Code Playgroud)

但它什么也没显示。

然后我试过了

df.xs([['G1','G2'],[1,3]]) 
Run Code Online (Sandbox Code Playgroud)

但它返回 …

python multi-index dataframe pandas

4
推荐指数
2
解决办法
373
查看次数

Coral Dev Board“mdt devices”找不到任何设备

我正在关注 Coral Dev Board 入门指南 - 开始使用 Dev Board ( https://coral.withgoogle.com/docs/dev-board/get-started/ )。一切正常,直到步骤 -通过 MDT 连接到板的外壳。我等了大约 5 分钟,直到闪烁完成,终端提示返回给我,然后我尝试了命令:

mdt devices

终端什么都不返回。不像指南说它应该返回我的主板主机名和 IP 地址。我检查了USB-C OTG和USB-C电源线,它们都连接良好。

我也试过这个解决方案:https : //superuser.com/questions/1452786/coral-dev-board-not-recongized-on-mdt-shell。我转到系统偏好设置下的网络,然后单击“+”图标,但我找不到孟德尔设备。

我正在使用在 macOS Catalina 上运行的 Macbook Pro。fastboot 和 mdt 命令都可以工作。

macos fastboot tpu google-coral

3
推荐指数
1
解决办法
2882
查看次数

标签 统计

dataframe ×1

fastboot ×1

google-coral ×1

macos ×1

multi-index ×1

pandas ×1

python ×1

tpu ×1