相关问题 更多 >
编程相关推荐
- java控制台返回扫描器捕获的第一件事,而不转移到其他代码块
- java无法使用Jedis Lib本地连接到aws上的ElasticCache群集
- java我正在尝试将GPS功能添加到我的安卓应用程序中,GPS坐标每次都是0.0,0.0
- Java/Selenium RemoteWebDriver/Maven/JUnit在尝试调用浏览器时获取空会话id
- java可自由拖动的TextView精细控件
- java如何找到使用特定端口的神秘服务?
- swing无法使用Ubuntu运行Java GUI程序
- .net如何在java GUI应用程序中读取终端流?
- 使用ApacheMaven打包时出现java错误
- java我需要帮助来制作文本框架
如果准备了一个表示字段的数据结构,这些字段的名称和长度按顺序排列,则可以在字典理解中应用该结构,将数据拆分为各个键和值。然后使用json模块转换字典
你可以这样做:
或者简化版本,如果您不需要创建可重用函数
string_to_dict=lambda input_str:{“field1”:input_str[:3],“field2”:input_str[3:7], “field3”:输入[7:] 字符串到dict(“ABCDE12345”)
df['stinrg_series'].映射(字符串到dict)