When I do the following I seem to wind up with the original df,
train['col1'] = train['col1'].sample(frac=1)
While if I use.values I get the shuffle I was after:
train['col1'] = train['col1'].sample(frac=1).values
I'm unclear why this happens - any insights?
Because the version without .values
keeps the index
and the column preserves its order.
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.