Traceback (most recent call last): File…
- User
Traceback (most recent call last): File "/home/alejandro/Documents/projects/forks/postoga/./postoga.py", line 262, in main() File "/home/alejandro/Documents/projects/forks/postoga/./postoga.py", line 258, in main master.run() File "/home/alejandro/Documents/projects/forks/postoga/./postoga.py", line 84, in run self.table = query_table(self.path) File "/home/alejandro/Documents/projects/forks/postoga/modules/make_query_table.py", line 47, in query_table loss["helper"] = loss["transcript"].str.rsplit(".", 1).str[0] File "/home/alejandro/miniconda3/envs/postoga/lib/python3.10/site-packages/pandas/core/strings/accessor.py", line 129, in wrapper return func(self, *args, **kwargs) TypeError: StringMethods.rsplit() takes from 1 to 2 positional arguments but 3 were given
- Assistant
The
TypeErroryou are encountering is due to incorrect usage of thersplitmethod on theStringMethodsaccessor of a pandasSeriesobject. The error message suggests that you are attempting to callrsplitwith 3 arguments, whereas it expects at most 2 arguments.The
rsplitmethod in pandas is used to split strings inSeries/Indexaround given separator/delimiter, working from the end of the string towards the front and returns a list of splits. The syntax forrsplitis:pythonSeries.str.rsplit(pat=None, n=-1)pat: String value, the delimiter or separator to split on. IfNone, splits on whitespace.- : Integer, the limit on the number of splits. If is not specified or is , there is no limit on the number of splits.