pandas implements the selection of values where dataframe satisfies a condition

  • 2021-06-28 12:54:55
  • OfStack

When reading the data, you find that you want to pick out the data with question marks in the sixth column of the data


import pandas as pd
 
data = pd.read_table('breast-cancer-wisconsin.data.txt',header=None,encoding='gb2312',sep=',')
 
data = data.drop(0, axis=1)
 
data = data[data[6] != '?']

Related articles: