Suppose that I have a list of song names
songlist = np.array(['1.mp3', '2.mp3','3.mp3'])
According to numpy documentation, there's a useful char function called rstrip
:
For each element in self, return a copy with the trailing characters removed.
Since the file extension is exactly located in the trailing of the string, so I try using this rstrip
to remove the file extensions
np.core.char.rstrip(songlist,'.mp3')
However, it gives me this following output
array(['1', '2', ''], dtype='
What am I doing wrong here? How to use the rstrip
function to remove the file extensions correctly?