none
Execute Python Script Error - itertools package RRS feed

  • Question

  • Good morning,

    I am working on a simple python script which i wanted to run with the Microsoft Azure Machine Learning Studio. This script uses the pacakge "itertools". Normally this package is included with the standard version of Python (2.6 and higher) and even running on Anaconda. I tested the script below on my local device which contains this package. However, the script  returns in an error when using MAMLS on all the given versions of Anaconda.

    Is there a solution to solve this error?

    Thank you in advance.

    Kind regards,

    Patrick Langeveld

    ######### Script ##########################

    def azureml_main(dataframe1, dataframe2):

        import pandas as pd
        import itertools
        x = pd.DataFrame(itertools.permutations("ab", 2))
        return (x)

    ######### Expected outcome ##########################

       0  1
    0  a  b
    b  a

    ########## Error ########################

    Error 0085: The following error occurred during script evaluation, please view the output log for more information:
    ---------- Start of error message from Python interpreter ----------
    Caught exception while executing function: Traceback (most recent call last):
      File "C:\server\invokepy.py", line 199, in batch
        odfs = mod.azureml_main(*idfs)
      File "C:\temp\1d13ccd94c7a47d3a4fffd07fe9876bd.py", line 51, in azureml_main
        x = pd.DataFrame(itertools.permutations("ab", 2))
      File "C:\pyhome\lib\site-packages\pandas\core\frame.py", line 257, in __init__
        raise TypeError("data argument can't be an iterator")
    TypeError: data argument can't be an iterator
    Process returned with non-zero exit code 1

    ---------- End of error message from Python  interpreter  ----------
    Start time: UTC 09/10/2019 05:02:34
    End time: UTC 09/10/2019 05:02:51

    ##################################

    Tuesday, September 10, 2019 6:21 AM

All replies

  • Hi,

    Please try the following and let me know if you have any more issues. Thanks.

    import pandas as pd
    import itertools
    
    def azureml_main(dataframe1 = None, dataframe2 = None):
        x = pd.DataFrame(list(itertools.permutations("ab", 2)))
        return x
        
    azureml_main()

    Regards,

    Azure CXP Community.

    Tuesday, September 10, 2019 9:02 PM
    Moderator