Python code works on JupyterNotebook (local) but not on Visual Studio Code (ssh)

Question:

So, I have a piece of code written in Python which works perfectly fine on my local Jupyter Notebook, BUT when I run the same piece of code on Visual Studio Code it doesn’t work.

This is the code:

for i in df.index:
        for j in columns:

            millis = round(int(df.loc[i, j].value / 1e+6))
            millis = np.array([millis])

            for x in millis:

                seconds = (x/1000)%60
                seconds = int(seconds)

                minutes = (x/(1000*60))%60
                minutes = int(minutes)

                hours = (x/(1000*60*60))%24

                hour = "%d:%d:%d" % (hours, minutes, seconds)

                df.loc[i,j] = hour

So, this is to turn previously converted columns from timedelta to it’s original values.

Everything works fine until the last line df.loc[i, j] = hour

For some strange reason, it works fine on my local Jupyter Notebook but that particular line doesn’t work on Visual Studio Code.

Asked By: Milton De Marte

||

Answers:

Maybe you have a certain pluggin that makes your code work in JupiterNotebook that you don’t have in VSC? Check your pluggins are try to install the same ones on VSC if you see any pluggins that you dont have.

Answered By: Code Squid

It was a problem with pandas version. Super weird! Can’t believe a simple dataframe.loc won’t work on a version a it did on other version

Answered By: Milton De Marte