|
楼主 |
发表于 2023-1-6 20:31:47
|
显示全部楼层
运行后出错,帮忙看下。
代码
import pandas as pd
import numpy as np
import shutil
import os
from os import path
import xlwt
import openpyxl
data = pd.read_excel('g:\\data.xlsx')
result = dict()
for line in data.split('\n'):
name, nums = line[0], list(map(float, line[1:].split()))
count = 0
for num in nums:
if num > 1:
count += 1
result[name] = count
for each in result.items():
print(*each)
出错代码是
Traceback (most recent call last):
File "C:/Users/Administrator/Desktop/pj.py", line 13, in <module>
for line in data.split('\n'):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\core\generic.py", line 5902, in __getattr__
return object.__getattribute__(self, name)
AttributeError: 'DataFrame' object has no attribute 'split'
帮忙把统计出来的一列,加到最后列。谢谢 |
|