python去除某列固定数字对应的整行方法

 想去除month列里的1,2,3,4,10,11,12月对应的行

留下5,6,7,8,9月

#!usr/bin/env python
# -*- coding:utf-8 -*-
"""
@author: Su
@file: deletestaion.py
@time: 2023/09/22
@desc:
"""
import pandas as pd

df = pd.read_excel('/lianxi/SPI.xlsx')
df = pd.DataFrame(df)

list = [1,2,3,4,10,11,12]
df1 = df[-df.month.isin(list)]
# print(df1)
df1.to_excel('/lianxi.xlsx', index=False)

 

posted @ 2023-09-25 10:36  秋刀鱼CCC  Views(28)  Comments(0Edit  收藏  举报