请大师帮忙,把AA列含有“淘汰”的行删除掉,剩下的组成新的数据帧,谢谢
请大师帮忙,把AA列含有“淘汰”的行删除掉,剩下的组成新的数据帧,谢谢import pandas as pd
data = [["2345", "A", "2022-12-20", "2.1016", "-0.72","2.8", "-0.77",78],
["004243", "C", "2022-12-15", "2.0891", ", 45","-0.77",98],
["519212", "B", "2022-12-10", "淘汰", "1.9733", "-0.77", "-3.29",567],
["162411", "E", "2022-12-9", "0.7071", "-1.64","25", "-1.46",789],
["007844", "FC", "2022-11-19", "淘汰", '8', "88","-1.46",834.8],
["163208", "G", "2022-11-10", "1.0440", "-0.40","" ,"-0.40",0.568]]
columns = ["编号", "名称", "日期", "AA", "BB","CC","DD","EE"]
df = pd.DataFrame(data, columns=columns)
df ``` python
import pandas as pd
data = [["2345", "A", "2022-12-20", "2.1016", "-0.72","2.8", "-0.77",78],
["004243", "C", "2022-12-15", "2.0891", ", 45","-0.77",98],
["519212", "B", "2022-12-10", "淘汰", "1.9733", "-0.77", "-3.29",567],
["162411", "E", "2022-12-9", "0.7071", "-1.64","25", "-1.46",789],
["007844", "FC", "2022-11-19", "淘汰", '8', "88","-1.46",834.8],
["163208", "G", "2022-11-10", "1.0440", "-0.40","" ,"-0.40",0.568]]
columns = ["编号", "名称", "日期", "AA", "BB","CC","DD","EE"]
df = pd.DataFrame(data, columns=columns)
# 找到 AA 列含有"淘汰"的行,并删除
df = df[~df['AA'].str.contains('淘汰')]
# 输出新数据框
print(df)
```
输出结果:
```
编号 名称 日期 AA BB CC DD EE
0 2345A2022-12-20 2.1016 -0.72 2.8 -0.77 78.0
1004243C2022-12-15 2.0891, 45 -0.77 98.0 NaN
3162411E 2022-12-9 0.7071 -1.64 25 -1.46789.0
5163208G2022-11-10 1.0440 -0.40 0.568
```
页:
[1]