如果我读excel,它读作
SKU Code Location Code GIT
123456 100 10
123456 200 20
123456 300 0
但实际上我的excel数据是
SKU Code Location Code GIT
123456 0100 10
123456 0200 20
123456 0300 0
我试过下面的方法
gitDataDF = pd.read_excel("filename.xlsx",
sheet_name='Sheet1', inferSchema='true'
,converters={'Location Code': str})
及
gitDataDF = pd.read_excel("filename.xlsx",
sheet_name='Sheet1', inferSchema='true'
,dtype={'Location Code': np.str})
更新1: 值的长度不是固定的。可能是
我该怎么做才能读得像现在这样。你能帮我解决这个问题吗
请参考我使用的Python版本-3.8
熊猫版本-1.0.5
您可以尝试使用f字符串:
相关问题 更多 >
编程相关推荐