Q: How to convert a dataframe from pandas to a list in Python I am trying to convert the below dataframe (or series) to a list given by Costs = []
I want to put the cost data from the series into the list to do an NPV calculation.
Any advise on the simplest way to do this is much appreciated.  Thanks
Series I want to convert to a list
Tried various things, nothing worked.

A: A simple way would simply to use the Series' function of to_list(). A quick usage example:
import pandas

lst = [1,2,3,4,5,6]
series = pandas.Series(lst)
new_list = series.to_list()

print(new_list)

# output
[1, 2, 3, 4, 5, 6]

Notably, DataFrame's do not have an equivalent function for conversion to a list, but it can convert it to_dict(). Utilising the orient option with "list" will make it a dictionary of lists, with each key in the dictionary being a column header.

A: You can do this:
Costs = df['Costs'].values.tolist()  # return [x,y,z...]

Costs = df.values.tolist() # return [[x],[y],[z]]

