数据帧值不变

2024-05-23 16:21:54 发布

您现在位置:Python中文网/ 问答频道 /正文

我现在正在用神经网络,用colaboratory,pandas和keras把脚趾弄湿。为了设置我的数据,我需要规范化所有的数据(对于这些数据,我通过除以最大值得到0到1之间的所有值)。然而,我遇到了两个问题。你知道吗

  1. 出于某种原因,“stroke\u count”列没有被修改,或者如果是的话,不管发生什么,它都被舍入为0。

  2. 我看到了 菲尔纳测向仪(7) 应该用括号内的值替换所有Null或NaN值,但它没有这样做。你知道吗

    # generating character dictionary & normalizing data
    
    hanzi_dict = {}
    
    hanzi_counter = 0
    
    df.fillna(7)
    for index, row in df.iterrows():
        hanzi_dict[str(hanzi_counter)] = row['charcter']
        hanzi_counter = hanzi_counter + 1
    
        df.at[index, 'radical_code'] = row['radical_code'] / 214.9 # max value of any radical
        df.at[index, 'stroke_count'] = row['stroke_count'] / 35.0    # max # of strokes
        df.at[index, 'hsk_levl'] = row['hsk_levl'] / 7             # max level + 1
    
    print(hanzi_dict) 
    
    display(df) 
    

Tags: of数据dfindexstrokecountcountercode