skip to Main Content

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.

2

Answers


  1. Chosen as BEST ANSWER

    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


  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search