“Python randomisieren Sie einen DataFrame Pandas” Code-Antworten

Python mischt zufällig die Reihen von Pandas DataFrame

# Basic syntax:
df = df.sample(frac=1, random_state=1).reset_index(drop=True)
# Where:
#	- frac=1 specifies returning 100% of the original rows of the 
#		dataframe (in random order). Change to a decimal (e.g. 0.5) if
#		you want to sample say, 50% of the original rows
#	- random_state=1 sets the seed for the random number generator and
#		is useful to specify if you want results to be reproducible
#	- .reset_index(drop=True) specifies resetting the row index of the
#		shuffled dataframe
Charles-Alexandre Roy

Python randomisieren Sie einen DataFrame Pandas

df = df.sample(frac=1).reset_index(drop=True)
Confused Chipmunk

Ähnliche Antworten wie “Python randomisieren Sie einen DataFrame Pandas”

Fragen ähnlich wie “Python randomisieren Sie einen DataFrame Pandas”

Weitere verwandte Antworten zu “Python randomisieren Sie einen DataFrame Pandas” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen