Take a peek at this relevant question. You can make your index a column in the pandas dataframe for output.
Right before your output within your python script @pscript
you can add: df.reset_index(inplace=True)
.
Then in your WITH RESULT SETS
statement you can add the index column first in the list:
WITH RESULT SETS(
(
MyIndex int,
Col1 FLOAT,
Col2 FLOAT,
Col3 FLOAT
));
Here is a full simplified example since I can't see your exact code:
EXEC sp_execute_external_script @language =N'Python',
@script=N'
import pandas as pd
s = pd.Series([5,6,7,8,9,10])
df = pd.DataFrame(s)
df.reset_index(inplace=True)
OutputDataSet = df
'
WITH RESULT SETS (( MyIndex int, test int ));