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
|
:return: DataFrame
|
||||||
"""
|
"""
|
||||||
columns = {'C': 'close', 'V': 'volume', 'O': 'open', 'H': 'high', 'L': 'low', 'T': 'date'}
|
columns = {'C': 'close', 'V': 'volume', 'O': 'open', 'H': 'high', 'L': 'low', 'T': 'date'}
|
||||||
frame = DataFrame(ticker) \
|
frame = DataFrame(ticker).rename(columns=columns)
|
||||||
.rename(columns=columns)
|
|
||||||
if 'BV' in frame:
|
if 'BV' in frame:
|
||||||
frame.drop('BV', 1, inplace=True)
|
frame.drop('BV', axis=1, inplace=True)
|
||||||
# group by date to eliminate duplicate ticks
|
|
||||||
frame.groupby('date').agg({
|
frame['date'] = to_datetime(frame['date'], utc=True, infer_datetime_format=True)
|
||||||
'volume': 'max',
|
|
||||||
'open': 'first',
|
# group by index and aggregate results to eliminate duplicate ticks
|
||||||
|
frame = frame.groupby(by='date', as_index=False, sort=True).agg({
|
||||||
'close': 'last',
|
'close': 'last',
|
||||||
'high': 'max',
|
'high': 'max',
|
||||||
'low': 'min',
|
'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
|
return frame
|
||||||
|
|
||||||
def populate_indicators(self, dataframe: DataFrame) -> DataFrame:
|
def populate_indicators(self, dataframe: DataFrame) -> DataFrame:
|
||||||
|
Loading…
Reference in New Issue
Block a user