我有两个DataFrames(1)水果,(2)市场。两者都有三行,表示为0,1,2,只有一行没有标题。
print fruit
0 apple
1 pear
2 melon
print market
0 apple
1 pear
2 melon
我想以整数打印索引并尝试下面但是很难进入
print market.iloc[np.where(fruit[0] == market)].index
Int64Index([0], dtype='int64')
print market.iloc[np.where(fruit[0] == market)].index.tolist
<bound method Int64Index.tolist of Int64Index([0], dtype='int64')>
print market.iloc[np.where(fruit[0] == market)].index.values
[0]
print market.iloc[np.where(fruit[0] == market)].index.get_values
<bound method Int64Index.get_values of Int64Index([0], dtype='int64')>
如果没有括号,我该怎么办才能打印0? 目标: 0
答案 0 :(得分:0)
这会有用吗?
print(list(market.index)[0])
print(list(fruit.index)[0])