【发布时间】:2022-06-24 00:41:57
【问题描述】:
我有一个 Python 程序:
import pandas as pd
import numpy as np
import warnings
warnings.filterwarnings('ignore')
# Read a CSV file:
name = pd.read_csv("users.csv", delimiter=";")
# Get the value of the row with index 0, column "Name"
name = users.iloc[0].get("Name")
# Supposedly replace the first user Name to np.NaN
users.iloc[0].replace(name , np.NaN, inplace=True)
我希望这会替换名称,但事实并非如此。 替换它的方法是:
Replace every name "name" with np.NaN ?
users.replace(name, np.NaN, inplace=True)
但是上一行不是要替换整个文件的名称吗?如何只替换行?
【问题讨论】: