Fw: Unable to convert pandas object to string

Albert-Jan Roskam sjeik_appie at hotmail.com
Sat Jun 24 09:14:42 EDT 2017


________________________________
From: Albert-Jan Roskam <sjeik_appie at hotmail.com>
Sent: Saturday, June 24, 2017 11:26:26 AM
To: Paul Barry
Subject: Re: Unable to convert pandas object to string

(sorry for top posting)

Try using fillna('') to convert np.nan into empty strings. df['desc'] = df.desc.fillna(''). Btw, np.object already is what best approximates str. I wish np.object had its own sentinel value for missing data instead of np.nan, which is a float.
________________________________
From: Python-list <python-list-bounces+sjeik_appie=hotmail.com at python.org> on behalf of Paul Barry <paul.james.barry at gmail.com>
Sent: Saturday, June 24, 2017 9:44:54 AM
To: Bhaskar Dhariyal
Cc: python-list at python.org
Subject: Re: Unable to convert pandas object to string

Any chance you could post one line of data so we can see what we have to
work with?

Also - have you taken a look at Jake VanderPlas's notebooks? There's lot of
help with pandas to be found there:
https://github.com/jakevdp/PythonDataScienceHandbook

Paul.

On 24 June 2017 at 10:32, Bhaskar Dhariyal <dhariyalbhaskar at gmail.com>
wrote:

> <class 'pandas.core.frame.DataFrame'>
> Int64Index: 171594 entries, 0 to 63464
> Data columns (total 7 columns):
> project_id          171594 non-null object
> desc                171594 non-null object
> goal                171594 non-null float64
> keywords            171594 non-null object
> diff_creat_laun     171594 non-null int64
> diff_laun_status    171594 non-null int64
> diff_status_dead    171594 non-null int64
> dtypes: float64(1), int64(3), object(3)
>
> not able to convert desc and keywords to string for preprocessing.
> Tried astype(str). Please help
> --
> https://mail.python.org/mailman/listinfo/python-list
>



--
Paul Barry, t: @barrypj <https://twitter.com/barrypj> - w:
http://paulbarry.itcarlow.ie - e: paul.barry at itcarlow.ie
Lecturer, Computer Networking: Institute of Technology, Carlow, Ireland.
--
https://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list