You can simple re-assign pd.Series
to the correct value:
pd.Series = pd.core.series.Series
This only works if there is a reference to the original function/class still around (in this case there is pd.core.series.Series
). In case you overwrite something that isn't references somewhere else this won't work.
Just to give another example (based on a question in the comments), suppose you overwrote list
, you can use the builtins
module (or the __builtin__
module in Python 2):
list = [1,2,3] # overwritten list
b = list(range(10)) # throws a "TypeError: 'list' object is not callable"
import builtins
list = builtins.list # restored
b = list(range(10)) # works
However often it's much easier to restart the Python interpreter (which should also work) and in some cases it might only be the only option (in case nothing else references the overwridden value.