Search code examples
pythoncommentsspyder

Python Spyder : How to comment a specific section of code?


This is an easy one :

I work with Spyder 3.7 IDE and i would like to comment only the part between the two stars ** in the following code to permit me to desactivate the concatenation of the df "dftwo" in agg :

agg = pd.concat([dfOne, **dfTwo,** dfThree])

I remember we had the following syntax in SAS but it does not work here :

agg = pd.concat([dfOne, /*dfTwo,*/ dfThree])

I also tried few combinations with ''' or # but it does not comment the specific code...

agg = pd.concat([dfOne, '''dfTwo,''' dfThree)]
  File "<ipython-input-107-a3c09b662840>", line 1
    agg = pd.concat([dfOne, '''dfTwo,''' dfThree)]
                                       ^
SyntaxError: invalid syntax

Thanks for your help !


Solution

  • This is not related to Spyder, Python does not support inline comments.

    You can do:

    agg = pd.concat([
        dfOne,
        # dfTwo,
        dfThree
    )]
    

    Or maybe:

    agg = pd.concat([df[i] for i in permitted_dfs])