I'm trying to run this code within a debugger on a server: https://stackoverflow.com/a/46294435
import pandas as pd
import datetime as dt
df_data = pd.DataFrame({'DateTime' : [dt.datetime(2017, 9, 1, 0, 0, 0),dt.datetime(2017, 9, 1, 1, 0, 0),dt.datetime(2017, 9, 1, 2, 0, 0),dt.datetime(2017, 9, 1, 3, 0, 0)], 'Data' : [1,2,3,5]})
df_timeRanges = pd.DataFrame({'startTime':[dt.datetime(2017, 8, 30, 0, 0, 0), dt.datetime(2017, 9, 1, 1, 30, 0)], 'endTime':[dt.datetime(2017, 9, 1, 0, 30, 0), dt.datetime(2017, 9, 1, 2, 30, 0)]})
print(df_data)
print(df_timeRanges)
func = lambda x: (df_data.DateTime >= x.startTime) & (df_data.DateTime <= x.endTime)
sol = df_data[df_timeRanges.apply(func, axis=1).any()]
print(sol)
I tested it on an online compiler and it works well https://www.online-python.com/gKUbw5OT7i
However, when I run it on a server through a python debugger (pdb), it doesn't seem to recognize the variable.
Image: pdb returns "*** NameError: name 'df_data' is not defined"
What can I do to fix it? What steps can I take to debug this issue?