我需要一些幫助來解決處理 pandas DataFrame 的問題。這是代碼:df.drop(df.index[0], inplace=True)df.columns = ['Mic. No.', 'X', 'Y', 'Z', 'Re. Pre.', 'Im. Pre.']df['Pre'] = df['Re. Pre.'] + df['Im. Pre.'] * 1jdf.drop(['Mic. No.', 'Re. Pre.', 'Im. Pre.'], axis=1, inplace=True)if z != 0: df = df.loc(df['Z'] == z)我在 panda 數(shù)據(jù)框中加載了 Excel 工作表?,F(xiàn)在,經(jīng)過一些預處理后,DataFrame 的形式如下: X Y Z Pre 1 0.16 0.16 0.05 (1.0048704-0.51310315j) 2 0.16 -0.16 0.05 (0.24814222-1.6094971j) 3 -0.16 0.16 0.05 (0.24815122-1.6094059j) 4 -0.16 -0.16 0.05 (1.0048704-0.51310315j) 5 -0.154993 0.154993 0.05 (-0.13939651-1.7231593j)現(xiàn)在我想刪除 DataFrame 中“Z”列中沒有值 z 的所有列。我收到錯誤:“TypeError:‘Series’對象是可變的,因此無法對它們進行哈希處理”。我不知道該怎么做,因為我所看到的與 pandas 文檔中的完全相同。https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.loc.htmldf.loc[df['shield'] > 6] max_speed shield sidewinder 7 8
添加回答
舉報
0/150
提交
取消