start index at 1 for Pandas DataFrame
Just set the index before writing to CSV.
df.index = np.arange(1, len(df) + 1)
And then write it normally.
source: In Python pandas, start row index from 1 instead of zero without creating additional column
Working example:
import pandas as pdas
dframe = pdas.read_csv(open(input_file))
dframe.index = dframe.index + 1
Index is an object, and default index starts from 0
:
>>> result.index
Int64Index([0, 1, 2], dtype=int64)
You can shift this index by 1
with
>>> result.index += 1
>>> result.index
Int64Index([1, 2, 3], dtype=int64)