In C++
, when I can't find a keyword in a table, it will return NULL
or in database it will return a empty table, so the program continues to run. But in python
, it throws an exception
, and interrupts my program. Can I avoid that?
for example, I have such a DataFrame named datevar
:
(datetimeIndex) value
2001-01-01 1
2001-01-02 1
2001-01-03 3
....
v = datevar.xs('2000-01-01', level='date') # of course "keyError"
v = datevar.loc['2000-01-01' , :] # of course "keyError"