I have multiple column that I need to slice with same condition I can see some solution here but they do not work with multiple column
df['x', 'y']=df['x', 'y'].str.slice(0,19)
Error
AttributeError: 'DataFrame' object has no attribute 'str'
You need to use the apply
function to a apply it on multiple columns:
df[['x','y']]=df[['x','y'].apply(lambda x:x.str.slice(0,19))
It should give the correct output.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments