以下是将 xls 文件转换为 npy 文件的 Python 代码:

import pandas as pd
import numpy as np

# 读取 xls 文件
data = pd.read_excel('example.xls')

# 将数据转换为 numpy 数组
array = np.array(data)

# 将 numpy 数组保存为 npy 文件
p.save('example.npy', array)

首先,我们使用 pandasread_excel 函数读取 'example.xls' 文件中的数据。然后,我们使用 numpyarray 函数将数据转换为 numpy 数组。最后,我们使用 numpysave 函数将 numpy 数组保存为 'example.npy' 文件。

Python 代码:将 XLS 文件转换为 NPY 文件

原文地址: https://www.cveoy.top/t/topic/mPY8 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录