CQL TypeError: Received an argument of invalid type for column

CQL TypeError: Received an argument of invalid type for column

我正在使用 Cassandra Python driver,我创建了一个 table,在 table 中有一列(称为日期)定义为 timestamp。我尝试从数据框中访问值并使用这些值将行插入到 table 中。与日期对应的数据帧值具有格式(从PyCharm调试模式捕获),

Timestamp('2006-09-29 00:00:00')

但是我得到了以下错误,

TypeError: Received an argument of invalid type for column "date". Expected: <class 'cassandra.cqltypes.DateType'>, Got: <class 'str'>; (DateType arguments must be a datetime, date, or timestamp)

table 定义为,

CREATE TABLE test_keyspace.test_table (
key1 text PRIMARY KEY,
key2 float,
key3 text,
key4 text,
key5 text,
date timestamp
) WITH bloom_filter_fp_chance = 0.01
AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
AND comment = ''
AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND crc_check_chance = 1.0
AND dclocal_read_repair_chance = 0.1
AND default_time_to_live = 0
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair_chance = 0.0
AND speculative_retry = '99PERCENTILE';

更新

问题是因为dataframe中有NaT,在插入cassandra之前忘记删除它们。

尝试改用 datetime.datetime(2016,09,29)