小编Vic*_*Vic的帖子

'module'对象没有属性'isna'

我有一个df调用batch_df,我在df中添加了'as_percentage'.如果小时是Nan,那么将as_percentage设置为0.代码在PyCharm中正常运行但是当我在终端上运行时,我收到了这个错误:请帮忙!

Traceback(最近一次调用最后一次):

在main()中输入文件"/Users/vic_ong/dev/resource-management/generateBatch.py​​",第166行

文件"/Users/vic_ong/dev/resource-management/generateBatch.py​​",第51行,主要

batch_df.loc [pd.isna(batch_df ['hours'])== False,'as_percentage'] = 0 AttributeError:'module'对象没有属性'isna'

编辑 - 我的代码如下所示:

#!/usr/bin/env python2
import lib
import pandas as pd
import datetime
import os
pd.set_option('expand_frame_repr', False)
# get directories
batchInputDir = '/Users/vic_ong/dev/resource-management/data/input/batchUpload'


def main():
# start timer
start_time = datetime.datetime.now()

# walk into every csv file in batchUpload and concatenate them into one df
list_ = []
for root, dirs, files in os.walk(batchInputDir):
    for file in files:
        if file.endswith('.csv'):
            df = pd.read_csv(os.path.join(batchInputDir, file), index_col=None, header=0)
            list_.append(df) …
Run Code Online (Sandbox Code Playgroud)

python python-2.7

1
推荐指数
1
解决办法
5961
查看次数

标签 统计

python ×1

python-2.7 ×1