[Tutor] Get all possible ranges of columns across a dataframe's

Dennis Lee Bieber wlfraed at ix.netcom.com
Thu Mar 30 22:02:43 EDT 2023


On Thu, 30 Mar 2023 22:14:41 +0200, marc nicole <mk1853387 at gmail.com>
declaimed the following:

>I want to get, accross its columns, the following output
>

	This sounds a lot like just a new variation of your previous question.
The similarity makes them seem to be a lot like home work assignments. The
main purpose of this forum to assist with questions about Python, not to
solve home work problems -- or designing algorithms.

	
>>
>> *from itertools import combinations        resultTmp2 = []        for j in
>> range(1, len(dataframe.columns) + 1):          resultTmp = []          for
>> xVal in list(combinations(dataframe.iloc[:len(dataframe) + 1,j-1],
>>  len(dataframe)  )):             resultTmp.append(list(xVal))
>> resultTmp2.append(resultTmp)        print(resultTmp2)*
>

	Please use a client that doesn't strip line endings and/or leading
spaces... That may mean NOT USING the Google/Gmail web access!

	That mess is unusable. Python requires white space (indentation) to
determine code blocks, and the above is completely not executable. It is
also incomplete -- where is dataframe defined?

	Walk through the code you have using /paper/ to track what each name is
bound to at each point of the code. That may show you where your algorithm
is deficient.





More information about the Tutor mailing list