Is there a way to use the astropy table indicies in the same way as Pandas dataframe indicies?

If I have some dataframe with indicies and if I need to slice it, indicies will be still in the sliced dataframe, whereas in astropy I didn’t find anything similar. I saw that there are also some indicies, but, if I got it right, they’re different and they’re not transferred in a sliced table (for example, if one chooses several columns from the main table).

It depends on what exactly you try to accomplish. If you just want to keep an index in your table that stays around, the easiest is probably to make a new index column:

tab ='abcd.fits')
tab['index'] = np.arange(len(table))

Then, that’s just a normal table column and when you slice and dice the table, the index will stay with each row.

Actually, I just wanted to use astropy tables as the arguments for “sklearn.model_selection.train_test_split” function, but there is a problem because the tables are not indexed. Therefore, I can’t use them instead of pandas dataframes.

Can you post details of the error you are seeing, i.e. what property is sklearn trying to access?