
[英]how to eliminate rows with continuous values for a column using python/pandas
[英]How to query dynamo db to retrieve rows with non null column values using python - pandas
我试图从 dynamodb 中提取不同事件的最后不是 null 偏移量。 我怎样才能在我的关键条件表达式中添加它。
我的表格存档包含以下列,
eventinfo temp_b temp_a 偏移量
C 12 27 90
乙 20 21 80
A 23 20 南
B 22 24 100(最后一个非 B 的 null 值)
A 22 29 20(最后一个非 null 值为 A)
A 23 22 南
B 22 24 南
预期结果:
事件 temp_b temp_a 偏移量
乙 22 24 100
22 29 20
我的代码如下,
dynamo = DynamoDbApi(logging.getLogger(), table_name = 'archive')
events = { 'first':'A','second':'B'}
frames = []
for event in events.values():
resp = dynamo.query_table(
KeyConditionExpression = (
Key('eventinfo').eq(event)
)
)
# convert to pandas data frame
df = pd.DataFrame(resp)
frames.append(df)
result = pd.concat(frames)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.