from chainer import datasets
from chainer.datasets import tuple_dataset
import numpy as np
import matplotlib.pyplot as plt
import chainer
import pandas as pd
import math
我有一个CSV文件,其中包含40300个数据。
df =pd.read_csv("Myfile.csv", header = None)
在该区域中,我正在删除忽略的行和列
columns = [0,1]
rows = [0,1,2]
df.drop(columns, axis = 1, inplace = True) #drop the two first columns that no need to the code
df.drop(rows, axis = 0, inplace = True) #drop the two first rwos that no need to the code
在此区域中,如果字符串数据类型面对但不起作用,我想删除该行
df[~df.E.str.contains("Intf Shut")]~this part is not working with me
df.to_csv('summary.csv', index = False, header = False)
df.head()
答案 0 :(得分:0)
您必须在df中重新分配df的值
df = df[~df.E.str.contains("Intf Shut")]
答案 1 :(得分:0)
必须将列名更改为数组,然后选择第三列
df[~df[2].isin(to_drop)]
然后,您可以先为包含的特定文本定义一个变量“ to_drop”,如下所示。
to_drop = ['My text 1', 'My text 2']