How to fetch a data entry from a pandas dataframe using a given value in index?
To fetch a row from dataframe given index x, we can use loc.
Df.loc[10] where 10 is the value of the index.
Code
import pandas as pd
bikes=["bajaj","tvs","herohonda","kawasaki","bmw"]
cars=["lamborghini","masserati","ferrari","hyundai","ford"]
d={"cars":cars,"bikes":bikes}
df=pd.DataFrame(d)
a=[10,20,30,40,50]
df.index=a
How to fetch a data entry from a pandas dataframe using a given value in index?
To fetch a row from dataframe given index x, we can use loc.
Comments
Leave a comment