Skip to content Skip to sidebar Skip to footer

Creating A List With Data From A Dataframe Index In Python

i'm facing troubles trying to convert the index of df (see code) into a list, because when i run it this list is a 'Timestamp' one (i dont know what that means). The code is quote=

Solution 1:

ts_list = df.index.tolist()  # a list of Timestamp's
date_list = [ ts.date() for ts in ts_list ]  # a list of datetime.date's
date_str_list = [ str(date) for date in date_list ]  # a list of strings

Post a Comment for "Creating A List With Data From A Dataframe Index In Python"