Closed allaway closed 4 years ago
yes, it was missing - strange for not rising an error for me, probably during testing the code I already defined s. Anyway thank you very much for testing it, putting s=0 there solves the problem, :)
Thanks! Writing out the csv in the next chunk also gives me a weird encoding error...are you familiar with this? :
---------------------------------------------------------------------------
UnicodeEncodeError Traceback (most recent call last)
<ipython-input-33-3bfaa550dd86> in <module>()
----> 1 meta_matrix.to_csv('../results/drugs_meta.csv',sep=',')
/home/ec2-user/anaconda3/envs/py2/lib/python2.7/site-packages/pandas/core/generic.pyc in to_csv(self, path_or_buf, sep, na_rep, float_format, columns, header, index, index_label, mode, encoding, compression, quoting, quotechar, line_terminator, chunksize, tupleize_cols, date_format, doublequote, escapechar, decimal)
3018 doublequote=doublequote,
3019 escapechar=escapechar, decimal=decimal)
-> 3020 formatter.save()
3021
3022 if path_or_buf is None:
/home/ec2-user/anaconda3/envs/py2/lib/python2.7/site-packages/pandas/io/formats/csvs.pyc in save(self)
170 self.writer = UnicodeWriter(f, **writer_kwargs)
171
--> 172 self._save()
173
174 finally:
/home/ec2-user/anaconda3/envs/py2/lib/python2.7/site-packages/pandas/io/formats/csvs.pyc in _save(self)
272 def _save(self):
273
--> 274 self._save_header()
275
276 nrows = len(self.data_index)
/home/ec2-user/anaconda3/envs/py2/lib/python2.7/site-packages/pandas/io/formats/csvs.pyc in _save_header(self)
240 if not has_mi_columns or has_aliases:
241 encoded_labels += list(write_cols)
--> 242 writer.writerow(encoded_labels)
243 else:
244 # write out the mi
UnicodeEncodeError: 'ascii' codec can't encode character u'\xd0' in position 9: ordinal not in range(128)
utf-8 encoding seems to fix this!
great! just came back to check it, but seems like its fine. thanks!
For this chunk:
I get the error
Apologies for all of the issues. I am an R person with only passing python familiarity...
Defining
s
in the finalelse
statement seems to fix this but it's not clear to me whether this is an appropriate fix:Let me know what you think!