简体   繁体   中英

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 !

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])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM