Why does the index seem to get appended to the first column of a .loc boolean selected row of a dataframe?
Dataframe:
date price
0 20180926 100
1 20180925 99
2 20180924 98
3 20180923 97
Code:
import pandas as pd
d = {'date': ['20180926', '20180925','20180924','20180923'], 'price': [100,99,98,97]}
df = pd.DataFrame(d)
a = df.loc[df['date'] == '20180924']
print(a['date'])
Yields:
2 20180924
Name: date, dtype: object
The "2" index seems to be automatically appended to the front of the 'date' field.
Whereas:
b=a.iloc[0]['date']
print(b)
Yields:
20180924
I expected both methods to yield the same result as 'b'.