Issue
Hi I have databases of different sizes! However, I would like to select only the Total column of the Values (red) for a calculation. But since this column is different for the different databases, I cannot write e.g. df.iloc[5:6, 1:2]
! is there another approach?
Solution
You can use .loc
to access a row specified by its index.
df1 = pd.DataFrame(np.random.randn(3), index=["a", "b", "Total"])
df2 = pd.DataFrame(np.random.randn(5), index=["a", "b", "c", "d", "Total"])
print(df1.loc["index"].values[0])
print(df2.loc["index"].values[0])
Answered By - GuillemB
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.