python - 将浮点数列表转换为熊猫中的多列浮点数
问题描述
我有pandas
一列包含 1000 的列表float
。但是,我不想有一列带有列表,而是希望有 1000 列的 1 float
。现在,这些列表与string
类型一起存储。
列表示例(裁剪):
[0.12953150272369385, 0.16092558205127716, -0.03718775138258934]
我知道可以通过遍历行并创建 1000 列并一一传递新值来做到这一点。但这会很慢。
有更快的方法吗?
解决方案
Put it in brackets so that you have a list of the list:
l = [0.12953150272369385, 0.16092558205127716, -0.03718775138258934]
pd.DataFrame(l)
Out:
0
0 0.129532
1 0.160926
2 -0.037188
pd.DataFrame([l])
Out:
0 1 2
0 0.129532 0.160926 -0.037188
推荐阅读
- c# - AutoMapper:缺少类型映射配置或不支持的映射,C#?
- python - Python/MySQL - 通过 Tkinter 将数据插入表中
- azure - 通过脚本在 Azure 云服务经典上启用/禁用反恶意软件扩展
- java - 使用 readObject() 反序列化一个类,并用 readObject 返回的实例“替换”您调用它的实例
- linux - 解决可加载内核模块 (LKM) 中不明确的外部符号引用
- azure - 在 azure 函数进程结束之前,应用程序洞察中的日志被切断
- html - 自定义 CSS 属性“背景颜色”不起作用
- python - CSRF 令牌不匹配 - 烧瓶 wtforms
- ios - 使用 Pinterest 单元格快速添加或删除单元格后,使用自定义布局调整 UICollectionView 的大小
- swift - Xcode - Up or Down 纸牌游戏 (Swift)