Reputation: 171
Trying to find the last index value and save to variable but I cant seem to pull only the index column alone. I want to be able to use the date to determine if new values have been generated.
Process is as follows:
df = pd.read_csv('USDT_XRP_4HOUR_JAN_2017.csv', index_col='date',delimiter=',')
print('INDEX - LAST 1 LINES')
print(df.iloc[-1:,-1])
print('END OF INDEX - LAST 1 LINES')
OUTPUT
END OF INDEX - LAST 1 LINES
date
2018-09-18 10:55:00 0.274509
Name: high, dtype: float64
END OF INDEX - LAST 1 LINES
Upvotes: 1
Views: 2325
Reputation: 2585
You access the index by the index
attribute of the dataframe. To get the last value, you could do this
df.index[-1]
or
df.index.values[-1]
Upvotes: 2