【发布时间】:2018-03-31 22:10:15
【问题描述】:
我想一次性更改一列中的连续行值块。
最后我得到了这个完成工作的方法,但我有点认为必须有一个更整洁的方法。
df = pd.read_excel('ja.xlsx')
df # echo the contents of the df
for index, row in df.iterrows():
if index < 4:
df.loc[ index, "my_col_name"] = 'yes'
else:
df.loc[ index, "my_col_name"] = 'no'
有什么建议吗?
谢谢!
【问题讨论】:
-
谢谢你——在询问之前我确实四处打猎,但他们都没有想到我所做的搜索
标签: pandas