I feel this is such a simple thing, however, I am hopelessly stuck. I have an excel df that I want to loop through and take values from to create an object.
cols = ['Net Transaction Amount', 'Original Value Transacted', 'First Name', 'Last
Name', 'Email', 'Transaction Date', 'Card Number', 'Card Expiration Date',
'Transaction Custom String1', 'Stripe ID', 'Payment Method', 'Total To-Date Gift
Amount', 'Start Date', 'Next Payment Date',]
bb_cus = pd.read_excel(loc,usecols=cols, header=0)
#for i in bb_cus:
#name = bb_cus['First Name'] +' '+ bb_cus['Last Name']
#print(name)
print(bb_cus)
Here is output:
Net Transaction Amount ... Next Payment Date
0 5 ... 2020-12-12 04:05:00
1 50 ... 2020-12-12 04:32:00
2 10 ... 2020-12-12 07:13:00
3 10 ... 2020-12-12 06:47:00
4 5 ... 2020-12-12 08:26:00
... ... ... ...
3593 10 ... 2020-12-01 13:48:00
3594 10 ... 2020-12-09 14:45:00
3595 10 ... 2020-11-14 11:29:00
3596 100 ... 2020-11-27 23:07:00
3597 Total ... NaT
[3598 rows x 14 columns]
I would like to be able to use a loop to take values from each row to create a new customer object in my DB. Something like this:
for i in bb_cus:
name = bb_cus['First Name']
print(name)
from here I get this. But I do not understand how to just get the name:
for i in bb_cus:
name = bb_cus['First Name']
print(name)
3597 NaN
Name: First Name, Length: 3598, dtype: object
0 Dianne
1 Jeff
2 Shawnna
3 Roman
4 Geri
...
3593 Richard
3594 Dezerae
3595 Amiya
3596 Michael
3597 NaN
How do I get just the name as a string rather than a new data object