Converting string_id to number_id
What you are looking for is performed exactly by sklearn.LabelEncoder, an example of which can be found here.

In your case:

from sklearn.preprocessing import LabelEncoder

encoder = LabelEncoder()
encoder.fit(["tt0984332", "tt0984332", "tt0847742", "ttnanana1"])

# Show the unique classes
print(encoder.classes_)
# out: array(['tt0847742', 'tt0984332', 'ttnanana1'], dtype='&lt;U9')

# Convert labels to integers
encoder.transform(["tt0984332", "tt0984332", "tt0847742", "ttnanana1"])
# out: array([1, 1, 0, 2])