Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'Timestamp' object has no attribute 'astype' #1023

Open
anegrean opened this issue Feb 23, 2024 · 0 comments
Open

AttributeError: 'Timestamp' object has no attribute 'astype' #1023

anegrean opened this issue Feb 23, 2024 · 0 comments

Comments

@anegrean
Copy link

Arctic Version

1.82.2

Arctic Store

TickStore

Platform and version

OS

NAME="Linux Mint"
VERSION="21.3 (Virginia)"
ID=linuxmint
ID_LIKE="ubuntu debian"

MongoDB

db version v6.0.13
Build Info: {
"version": "6.0.13",
"gitVersion": "3b13907f9bdf6bd3264d67140d6c215d51bbd20c",
"openSSLVersion": "OpenSSL 3.0.2 15 Mar 2022",
"modules": [],
"allocator": "tcmalloc",
"environment": {
"distmod": "ubuntu2204",
"distarch": "x86_64",
"target_arch": "x86_64"
}
}

Python

Python 3.10

Description of problem and/or code sample that reproduces the issue

AttributeError: 'Timestamp' object has no attribute 'astype'

Code

import pandas as pd
from datetime import datetime as dt

from arctic import Arctic, TICK_STORE
from arctic.date._mktz import mktz

db = Arctic('localhost')
db.delete_library('temp')
db.initialize_library('temp', lib_type=TICK_STORE)
tickstore_lib = db['temp']

data = [{'A': 120, 'D': 1}, {'A': 122, 'B': 2.0}, {'A': 3, 'B': 3.0, 'D': 1}]
tick_index = [dt(2013, 6, 1, 12, 00, tzinfo=mktz('UTC')),
dt(2013, 6, 1, 11, 00, tzinfo=mktz('UTC')), # Out-of-order
dt(2013, 6, 1, 13, 00, tzinfo=mktz('UTC'))]

data = pd.DataFrame(data, index=tick_index)

tickstore_lib._chunk_size = 3
tickstore_lib.write('SYM', data)
print(tickstore_lib.read('SYM', columns=None).index)

Traceback


AttributeError Traceback (most recent call last)
Cell In[73], line 21
18 data = pd.DataFrame(data, index=tick_index)
20 tickstore_lib._chunk_size = 3
---> 21 tickstore_lib.write('SYM', data)
22 print(tickstore_lib.read('SYM', columns=None).index)

File ~/miniforge3/envs/trading2/lib/python3.10/site-packages/arctic/tickstore/tickstore.py:600, in TickStore.write(self, symbol, data, initial_image, metadata)
597 self._assert_nonoverlapping_data(symbol, to_dt(start), to_dt(end))
599 if pandas:
--> 600 buckets = self._pandas_to_buckets(data, symbol, initial_image)
601 else:
602 buckets = self._to_buckets(data, symbol, initial_image)

File ~/miniforge3/envs/trading2/lib/python3.10/site-packages/arctic/tickstore/tickstore.py:621, in TickStore._pandas_to_buckets(self, x, symbol, initial_image)
619 rtn = []
620 for i in range(0, len(x), self._chunk_size):
--> 621 bucket, initial_image = TickStore._pandas_to_bucket(x[i:i + self._chunk_size], symbol, initial_image)
622 rtn.append(bucket)
623 return rtn

File ~/miniforge3/envs/trading2/lib/python3.10/site-packages/arctic/tickstore/tickstore.py:729, in TickStore._pandas_to_bucket(df, symbol, initial_image)
721 col_data = {
722 DATA: Binary(lz4_compressHC(array.tobytes())),
723 ROWMASK: rowmask,
724 DTYPE: TickStore._str_dtype(array.dtype),
725 }
726 rtn[COLUMNS][col] = col_data
727 rtn[INDEX] = Binary(
728 lz4_compressHC(np.concatenate(
--> 729 ([recs[index_name][0].astype('datetime64[ms]').view('uint64')],
730 np.diff(
731 recs[index_name].astype('datetime64[ms]').view('uint64')))).tobytes()))
732 return rtn, final_image

AttributeError: 'Timestamp' object has no attribute 'astype'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@anegrean and others