I'm running Spyder on Python 3.7 and am new to modin. I want to retrieve the first characters in a string and save to a new column. When I run the usual with pandas it works:
import pandas as pd
data = pd.read_csv('Path/data.csv', dtype=str, encoding='utf-8')
data['FL_x']=data['x'].str[0:3]
But when I run the same with modin I get the error: 'TypeError: 'StringMethods' object is not subscriptable'
import modin.pandas as pd
#etc.
I can solve the problem by using str.get():
data['FL_x']=data['x'].str.get(0) + data['x'].str.get(1) + data['x'].str.get(2)
But it is very time-consuming for large amounts of data and checking many first characters.
Is there a simple way to immediately retrieve the first z characters in a string with modin as with pandas?
You could try:
data['FL_x']=data['x'].str.slice(stop=3)