Wolfy
Wolfy

Reputation: 458

Get just the numbers from the dataframe

I have this dataframe with one column:

                                   0
UPB                         2.260241e+08
Voluntary Payoffs           0.000000e+00
Involuntary Payoffs         3.169228e+06
Loan Loss                   0.000000e+00
Cost Basis                  2.221221e+08
Cost Basis Liquidated       3.149118e+06
Escrow Advances             0.000000e+00
Corp Advances               0.000000e+00
Loan Count                  6.670000e+02
Loan Count of Paying Loans  5.510000e+02

I want to just get the numbers into a list. I tried using iloc, ix, etc... but I am not getting just the numbers.

Upvotes: 0

Views: 34

Answers (2)

Scriddie
Scriddie

Reputation: 3821

Selecting the column and converting it to a list like so should solve your problem:

df = pd.DataFrame({"0": [1,2,3]})
print(list(df["0"]))

Upvotes: 0

thetradingdogdj
thetradingdogdj

Reputation: 521

df.values.squeeze().tolist()

And if you want a better format:

df.values.apply(lambda x: np.round(x, 2)).squeeze().tolist()

Upvotes: 1

Related Questions