I have created a static method that creates a random training protocol for the participants involved in an experiment. The method works but I want the training day to always start with 'STRAIGHT-GLIDING'. Is there a simple way I can do this in Pandas?
I have tried to use .loc but it turns out that this overwrites the existing values, and that's not what I want.
Thanks Christian
@staticmethod
def allokeringRandom(printToCSV=False):
dn = []
for i in range(1, 4):
df = pd.DataFrame()
loype = ['STRAIGHT-GLIDING','STRAIGHT-GLIDING','LØYPE 1', 'LØYPE 1', 'LØYPE 1', 'LØYPE 2', 'LØYPE 2', 'LØYPE 2', 'LØYPE 3', 'LØYPE 3', 'LØYPE 3']
dn.append(random.sample(loype, len(loype)))
df = pd.DataFrame(dn).transpose()
df = df.rename(columns={0: "Treningsdag 1", 1: "Treningsdag 2", 2: "Treningsdag 3"})
if printToCSV == True:
df.to_csv('test3.csv')
DataFrame
insidefor
-loop if you don't use it ?STRAIGHT-GLIDING
beforefor
-loop -dn = ['STRAIGHT-GLIDING']
- and then it will be first on list.