I have dataset like this from csv file.
I want to remove all records that has question mark ('?') in any of their column. I tried this code:
for column in df.columns: df = df[df[column]?= ' ']
But it does not work, here is the output. My expected output is index 1 and 3 get removed. How can i achieve that?
Filter all rows without ?
with space:
out = df[(df?= '.') all(axis=1)]
Or if possible use read_csv
and no missing values, only ?
use:
out = pd.read_csv(file, na_values='?').dropna()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.