Use index=False to ignore index. Let us first import the required library −
import pandas as pd
Create a DataFrame −
dataFrame = pd.DataFrame([[10, 15], [20, 25], [30, 35]],index=['x', 'y', 'z'],columns=['a', 'b'])
Select rows by passing label using loc −
dataFrame.loc['x']
Display DataFrame without index −
dataFrame.to_string(index=False)
Example
Following is the code −
import pandas as pd # Create DataFrame dataFrame = pd.DataFrame([[10, 15], [20, 25], [30, 35]],index=['x', 'y', 'z'],columns=['a', 'b']) # DataFrame print"Displaying DataFrame with index...\n",dataFrame # select rows with loc print"\nSelect rows by passing label..." print(dataFrame.loc['x']) # display DataFrame without index print"\nDisplaying DataFrame without Index...\n",dataFrame.to_string(index=False)
Output
This will produce the following output −
Displaying DataFrame with index... a b x 10 15 y 20 25 z 30 35 Select rows by passing label... a 10 b 15 Name: x, dtype: int64 Displaying DataFrame without Index... a b 10 15 20 25 30 35