Python Forum
can't get rid of '?' within my df!
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
can't get rid of '?' within my df!
#1
Just gotten back on the laptop after an extended break and can't seem to complete this simple task! I've got a large dataset, and just going about my preprocessing and I can't seem to mark and drop the rows with a '?'. I've tried repeatedly to replace said '?'s with NaN so I can drop them willy nilly, though nothing seems to be affecting the dataset whatsoever.

Most seem to drop the rows if a value occurs in a particular column, though I don't want to go through each column, rather just the entire dataset at once. Also because my rows have different types then that perhaps is causing some friction: all mixed between float and object.


Here's what I've tried:

train = pre_train.replace('?', 'np.Nan')

train = pre_train.replace({'?': np.nan}).dropna()

train = pre_train.replace({to_replace = "?", value = "NaN"})

train = pre_train.where(pre_train != '?', other = 'NaN')
And I can't seem to get any to work, so any help is appreciated. Will offer a little segment of what the dataset looks like (note there are more columns). If I do the opposite and attempt to rid my df of all rows that contain an element that is not '?', and I manage to clear the df, so really confused by this!

[Image: r2TD02D]

I can't seem to work out how to edit my original post, so if a mod could join these two together I would be eternally grateful!
Reply


Messages In This Thread
can't get rid of '?' within my df! - by brkolvr - Aug-13-2019, 05:07 PM
RE: can't get rid of '?' within my df! - by scidam - Aug-13-2019, 11:16 PM
RE: can't get rid of '?' within my df! - by brkolvr - Aug-14-2019, 02:33 PM
RE: can't get rid of '?' within my df! - by brkolvr - Aug-15-2019, 05:07 PM
RE: can't get rid of '?' within my df! - by scidam - Aug-16-2019, 01:12 AM
RE: can't get rid of '?' within my df! - by brkolvr - Aug-16-2019, 01:36 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020