In Python Pandas, how do you find the numerical index of a dataframe?
Consider the following example.
import pandas as pd
df = pd.DataFrame(np.arange(20).reshape(5,4), index = np.arange(2,7),columns=["A","B","C","D"])
Output:
A B C D
2 0 1 2 3
3 4 5 6 7
4 8 9 10 11
5 12 13 14 15
6 16 17 18 19
How do you find the location index of the df.index == 4. The answer should be 2.