python - 处理networkx中的时间戳
问题描述
尝试GEXF
从 networkx 写入文件时:
import pandas as pd
import networkx as nx
data = pd.DataFrame({'src':[1,2], 'dst':[2,1], 'attr_1':['foo', 'bar'], 'time':[pd.Timestamp.now(), pd.Timestamp.now()]})
G = nx.from_pandas_edgelist(data, source='src',
target='dst',
edge_attr=['attr_1', 'time'],
create_using= nx.MultiGraph())
nx.write_gexf(G, "visualization.gexf")
错误:
attribute value type is not allowed: <class 'pandas._libs.tslibs.timestamps.Timestamp'>
可以观察到。除了字符串格式化networkx的时间戳之外没有其他方法来处理它吗?
解决方案
推荐阅读
- javascript - 隐式上下文未定义,角度 7
- swift - 在 Swift 中生成重叠
- javascript - 当他/她点击某个按钮时存储用户的电子邮件
- r - 仅过滤使用 dplyr 重复的行
- windows - DPAPI 主密钥迁移到新计算机
- python - 使用 Python 访问 Json 变量时出现 cx_Oracle 错误
- java - 更改 BottomNavigationView 中的片段时如何保存数据?
- java - 异或交换代码与java中的临时变量交换代码
- swift - Swift Closures: Must Capture Lists Be Exhaustive?
- javascript - Office.js POST 方法被转换为 GET