[Baypiggies] Pandas question

Pete[r] Landwehr pmlandwehr at gmail.com
Sat Feb 10 02:12:01 EST 2018


I think you're just misreading the file - despite having a csv suffix, the
file is delimited with semicolons (or at least the columns are). Try
data = pd.read_table('examples/data/bank.csv', header=0, sep=';')

On Fri, Feb 9, 2018 at 3:29 PM, Braun Brelin <bbrelin at gmail.com> wrote:

> 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
>
>
>
>
>
> _______________________________________________
> Baypiggies mailing list
> Baypiggies at python.org
> To change your subscription options or unsubscribe:
> https://mail.python.org/mailman/listinfo/baypiggies
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/baypiggies/attachments/20180209/b13a7705/attachment-0001.html>


More information about the Baypiggies mailing list