可以通过以下步骤实现:
import pandas as pd
ser = pd.Series([1, 2, 3, 4, 5])
rows_to_delete = [1, 3]
new_ser = ser.drop(index=rows_to_delete)
print(new_ser)
完整的代码如下:
import pandas as pd
ser = pd.Series([1, 2, 3, 4, 5])
rows_to_delete = [1, 3]
new_ser = ser.drop(index=rows_to_delete)
print(new_ser)
这样,根据列表从pandas序列中删除行的操作就完成了。
推荐的腾讯云相关产品:腾讯云数据库TDSQL,产品介绍链接地址:https://cloud.tencent.com/product/tdsql
领取专属 10元无门槛券
手把手带您无忧上云