When I apply f"" string on my text data it procduces the following error. AttributeError: 'str' object has no attribute 'str'
.
The simple code is below, I am providing just one line so that it will save your time. I just want to apply f"" in this way. I know the problem but don't know how to figure it. Thanks
caption = f"{caption.str.lower().str.rstrip('.')}"
CodePudding user response:
You may be familiar with the pandas library's .str
accessor which make pandas ports of python string methods available to a Series. But if you're working with python builtin str
types, you don't need the .str
accessor. Simply call:
caption = f"{caption.lower().rstrip('.')}"
See the python builtin types docs on string methods for more info.