I would like to select specifics rows when reading a csv with pandas but I also would like to keep the last 5 to 8 columns as a one column because they all represent "genres" in my case.
I have tried to put the flag usecols=[0,1,2,np.arange(5,8)] when using pd.read_csv bubt it does not work.
If I use the flag usecols=[0,1,2,5], I just get one genre in the last column and the others (6, 7, 8) are lost.
I have tried the following but without succeeding:
items = pd.read_csv(filename_item,
sep='|',
engine='python',
encoding='latin-1',
usecols=[0,1,2,np.arange(5,23)],
names=['movie_id', 'title', 'date','genres'])
My CSV looks like:
2|Scream of Stone (Schrei aus Stein)|(1991)|08-Mar-1996|dd|xx|drama|comedia|fun|romantic
And I would like to get:
2 - Scream of Stone (Schrei aus Stein) - (1991) - 08-Mar-1996 - drama|comedia|fun|romantic
, where what I drew separated by "-" should be a column of the dataframe.
Thank you