[BangPypers] My querry

Abhiram R abhi.darkness at gmail.com
Tue Sep 24 03:42:58 EDT 2019


On Tue, Sep 24, 2019 at 1:04 PM Bappa Bhalsing via BangPypers <
bangpypers at python.org> wrote:

> Hello All,
> I am trying to run following program using python and i am getting error
> consistently.
> Please to resolve.
> input_file = '.\Desktop\height-weight.csv'import pandas as pd
> from pandas import DataFrame as df
> df = pd.read_csv(input_file)df.head()
> o/p is OK
> df('height') = df['Height(inches)'].map(lambda inches: round(inches *
> 0.83322 , 2))df.head()
> getting following errorFile "<ipython-input-9-2a96b594216d>", line 1
>     df('height') = df['Height(inches)'].map(lambda inches: round(inches *
> 0.83322 , 2)),
>
>               ^
> SyntaxError: can't assign to function call
>
>
>
Hi Bappa,
Glad to see doubts being posted on the Bangpypers mailing list as advised
by Anand.
Please use some pasting tool like https://pastebin.com/ for future queries
and provide the links so people can view your code more easily.

As for this particular issue, Python interprets "df" like a function
because you're using it like a function by passing 'height' as a parameter.
If you want to assign the modified value of 'Height (inches)' to a new
column, you have to create it as
df['height'] = ...

Modified your code here - https://pastebin.com/H8uMGKEC

Hope this helps.

Abhiram R

<http://abhiramr.com/>
*PS - *
This is an amazing tutorial for Pandas etc -
https://www.youtube.com/watch?v=Iqjy9UqKKuo&vl=en
The same channel has other tutorials for Python as well, should you need it.


> Regards,
> Bappa
>
>
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> https://mail.python.org/mailman/listinfo/bangpypers
>


-- 
-Abhiram R


More information about the BangPypers mailing list