예제 #1
0
def projectID_to_dict(df):
    """
    Convenience function to convert string of dict to dict type
    """
    if df.columns.nlevels > 1:
        return df.assign(projectID=(df.projectID.stack().dropna().apply(
            lambda ds: liteval(ds)).unstack()))
    else:
        return df.assign(projectID=df.projectID.apply(lambda x: liteval(x)))
예제 #2
0
for i in range(n):
	trainspeeds.append(i+1)
	
trainspeedsCombs = list(permutations(trainspeeds, n))

for i in range(len(trainspeedsCombs)):
	permutation = trainspeedsCombs[i]
	permutation = str(permutation)
	outcomes.append(permutation)

outcomesList = str(outcomes)

outcomesList = outcomesList.replace('(','[')
outcomesList = outcomesList.replace(')',']')
outcomesList = outcomesList.replace("'",'')
outcomes = liteval(outcomesList)

for i in range(len(outcomes)):
	outcome = outcomes[i]
	index = -1
	for j in range(len(outcome)-1):
		index += 1
		last = outcome[(-index)-1]
		notLast = outcome[(-index)-2]
		
		if notLast > last:
			outcome.remove(notLast)
			index = -1
			
		if last > notLast:
			continue