更新时间:2023-11-14 22:51:46
您需要将修剪后的列分配回原始列,而不是进行子集设置,并且 str.replace
方法似乎没有 to_replace
和 value
参数。而是使用 pat
和 repl
参数:
You need to assign the trimmed column back to the original column instead of doing subsetting, and also the str.replace
method doesn't seem to have the to_replace
and value
parameter. It has pat
and repl
parameter instead:
df["Date"] = df["Date"].str.replace("\s:00", "")
df
# ID Date
#0 1 8/24/1995
#1 2 8/1/1899