parse_ticker_dataframe: use as_index=False to keep date column
This commit is contained in:
parent
02aacdd0c8
commit
4f2d3dbb41
@ -46,20 +46,20 @@ class Analyze(object):
|
||||
:return: DataFrame
|
||||
"""
|
||||
columns = {'C': 'close', 'V': 'volume', 'O': 'open', 'H': 'high', 'L': 'low', 'T': 'date'}
|
||||
frame = DataFrame(ticker) \
|
||||
.rename(columns=columns)
|
||||
frame = DataFrame(ticker).rename(columns=columns)
|
||||
if 'BV' in frame:
|
||||
frame.drop('BV', 1, inplace=True)
|
||||
# group by date to eliminate duplicate ticks
|
||||
frame.groupby('date').agg({
|
||||
'volume': 'max',
|
||||
'open': 'first',
|
||||
frame.drop('BV', axis=1, inplace=True)
|
||||
|
||||
frame['date'] = to_datetime(frame['date'], utc=True, infer_datetime_format=True)
|
||||
|
||||
# group by index and aggregate results to eliminate duplicate ticks
|
||||
frame = frame.groupby(by='date', as_index=False, sort=True).agg({
|
||||
'close': 'last',
|
||||
'high': 'max',
|
||||
'low': 'min',
|
||||
'open': 'first',
|
||||
'volume': 'max',
|
||||
})
|
||||
frame['date'] = to_datetime(frame['date'], utc=True, infer_datetime_format=True)
|
||||
frame.sort_values('date', inplace=True)
|
||||
return frame
|
||||
|
||||
def populate_indicators(self, dataframe: DataFrame) -> DataFrame:
|
||||
|
Loading…
Reference in New Issue
Block a user