last day (15 days later) » 

4:41 PM
Afternoon
 
Hiya
So what are you trying to do , maybe you can paste me your code and/or paste the error it generates
 
i apprecate your help
data.astype(str).fillna(0,inplace= True)
wouldnt this take all the data turn it into a str and then apply fillna?
or does fillna onl work on float and int?
only*
and would it be easier to fo data.fillna(0,inplace= True).astype(str)
is it order of operations then?
 
1) fillna will work on a col with strings, I think. fillna will replace None's, or np.NaN values, regardless of column type
2) Yes order of operations is important, looks like df.astype(str) will try to replace np.NaN with the string 'nan', maybe you're seeing that now...
 
yeah so data.dtypes shows nan
everywhere
sorry object
so i wasnt sure if 1. astype(str) was working
and 2. if fillna should be 0
which to the user would be best
 
Sounds like, as you said, this order of operations is important, and should work:
data.fillna(0).astype(str)
 
4:50 PM
ok thanks
 
Be careful when you do data.fillna(0, inplace= True), you are changing the dataframe called data, so if you try to run the same data object again, it may haev already been converted to strings
 
really appreciate you reaching out
 
(i.e. especially common if you're using a Jupyter Notebook or something)
 
sypder ide
 
Ok with Spyder I think you're re-running a Python program (*.py) file each time you try this, just be careful , after this line is run, then data will have all 0's ,
data.fillna(0,inplace= True).astype(str)

It's a fine approach, but just be careful. You could do this instead, so that data is not modified; instead you have a new variable

data_with_zeroes = data.fillna(0).astype(str)
Lemme know if any other issues are affecting you, I may request you to paste more of your code (i.e. 3 or 4 lines at least)
 
4:54 PM
thats fine, i am pulling from an external source
so im just trying to convert items so I can run sklearn on them
so if it messes up i make secondary dataframes
 
I'm confused why "convert items (to string??) so I can run sklearn on them"
I thought sklearn would not want strings...
 
true
initally i was working through
so when i needed to do preprocessing it wouldnt do it on items unless i converted to string
thanks for your help on this
really appreciate it
 
No problem, hope it was helpful :)
I'll leave the chat now, good luck
 

last day (15 days later) »