I have pretty messy data I am trying to replace rows that might contain only 1 word or string with '' or empty string.
Here is the original data:
df = pd.DataFrame({'some_text': [
'I enjoy read Mark Twain\'s Books',
'Library is very useful',
'/',
'\\',
'/ /',
'',
'I enjoy read Mark Twain\'s Books',
'an',
'the',
'Books are interesting'
]})
I tried this: ( this is dropping rows). I don't want to drop the rows just replace it.
count = df['some_text'].str.split().str.len()
df[~(count==1)]
Final output needed:
I enjoy read Mark Twain's Books
Library is very useful
/ /
I enjoy read Mark Twain's Books
Books are interesting