The error message indicates that you are trying to assign a scalar value to a DataFrame using loc, but the DataFrame has no defined index.

To resolve this issue, you need to set the DataFrame index before assigning values using loc. You can do this by using the set_index method on your DataFrame, specifying the column that you want to set as the index.

Here's an example of how you can set the index and assign a value using loc:

df = df.set_index("编号")  # Set "编号" column as the index
df.loc[mailNumber, "到达时间"] = tdopTimeStart  # Assign value to "到达时间" column for the specified mailNumber

Make sure to replace "编号" with the actual column name in your DataFrame, and mailNumber and tdopTimeStart with the appropriate values in your code.

dflocdf编号 == mailNumber 到达时间 = tdopTimeStart1809 in _setitem_with_indexer raise ValueErrorValueError cannot set a frame with no defined index and a scalar

原文地址: https://www.cveoy.top/t/topic/i6MA 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录