I want to change the value_counts
function in pandas, and I try to figure out why it is not working.
If I do
>>> import pandas as pd
>>> pd.core.algorithms.value_counts = None
>>> pd.Series([1,2,3]).value_counts()
3 1
2 1
1 1
dtype: int64
I would expect to have a TypeError
However if I do
>>> import pandas as pd
>>> pd.core.base.value_counts = None #or a modified function
>>> pd.Series([1,2,3]).value_counts()
TypeError: 'NoneType' object is not callable
I get the TypeError
.
What is the reason of this difference of behavior?
How I can modify the pd.core.algorithms.value_counts
function such that it changes the behavior of all classes that use it to construct value_counts
methods?