[Baypiggies] Pandas question

Braun Brelin bbrelin at gmail.com
Fri Feb 9 18:29:32 EST 2018


Hello all,  I've got some data that I've loaded into a pandas dataframe via
the read_csv method.

The code looks like this:
data = pd.read_csv('examples/data/bank.csv', header=0) data = data.dropna()
print (data.shape) print (list(data.columns))

The output looks like this:

(4521, 1)
['age;"job";"marital";"education";"default";"balance"
;"housing";"loan";"contact";"day";"month";"duration";"
campaign";"pdays";"previous";"poutcome";"y"']

However,

When I try to access a column by key, I get a key error.
I.e.

print (data['education']) gives me a key error.

In fact, any of the data columns that I put in fails. I also ran

for key in data.keys():
print (keys)

That got me:

age;"job";"marital";"education";"default";"balance";"housing";"loan";"contact";"day";"month";"duration";"campaign";"pdays";"previous";"poutcome";"y"


Anyone know why I can't access the data in the df via key?


Thanks,


Braun Brelin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/baypiggies/attachments/20180209/c20a0dbd/attachment.html>


More information about the Baypiggies mailing list