首页 > 解决方案 > Python pandas,如何将特定的excel日期转换为json

问题描述

我有一个 excel 文件,想将 excel 转换为 json 文件。

这是我的擅长

            1 Year Period         2 Year Period      
 Max      10%                     11%
 Period   Jul 1996 to 1997        Jul 1997 to 1998
 Min      -30%                    -40%
 Period   mar 2002 to Mar 2003     mar 2003 to mar 2004

这是我想要的 Json 格式

                    "from": {
                        "month": 6,
                        "year": 1996
                    },
                    "to": {
                        "month": 6,
                        "year": 1997
                    }

问题是如何将“Period”行(例如 Jul 1996 到 1997)转换为 json 格式,例如

from": { "month": 6, "year": 1996 }, "to": { "month": 6, "year": 1997 } 

标签: pythonjsonexcelpandas

解决方案


推荐阅读