I am trying to use pandas str.replace function to replace a pattern.
But when i do:
pd.DataFrame({'text_col':['aaa', 'c', 'bbbbb', 'ddd']})['text_col'].str.replace('.*', 'RR')
it for some reason returns:
0    RRRR
1    RRRR
2    RRRR
3    RRRR
Name: text_col, dtype: object
While i would have though it should return the same as:
pd.DataFrame({'text_col':['aaa', 'c', 'bbbbb', 'ddd']})['text_col'].str.replace('^.*$', 'RR')
which returns:
0    RR
1    RR
2    RR
3    RR
Name: text_col, dtype: object
If i compare this behavior to R programming language, replacing the pattern .* and ^.*$ yields the same result. Why is it different in Pandas?