Find the matching string values โโand extract them separately, without specifying the match value (key)
I am trying to extract rows with matching Sample_IDs in the dataframe below:
df1 = pd.DataFrame([[1, 1.0, 2.3,0.2,0.53], [2, 3.35, 2.0,0.2,0.65], [2,3.4,
2.0,0.25,0.55], [3,3.4,2.0,0.25,0.55]],
columns=["Sample_ID", "NaX", "NaU","OC","EC"])\
.set_index('Sample_ID')
In the above df1 dataframe, I would like to get only rows with Sample_ID of "2". Is there a way to do this without specifying the appropriate values, key?
As a result, I am looking for:
NaX NaU OC EC
Sample_ID
2 3.35 2.0 0.20 0.65
2 3.40 2.0 0.25 0.55
Thanks for reading this!
+3
source to share
3 answers