delta-mpc / crypten_vfl_demo

vertical federated learning demo with crypten
MIT License
42 stars 6 forks source link

数据预处理中遇到的问题 #2

Open aaawu opened 3 years ago

aaawu commented 3 years ago

您好,在进行数据预处理这一步时,报错: ValueError: Number of passed names did not match number of header fields in the file 网上查询后的解决方案是: 使用names参数时,类似重命名。切记,要与原数据全部匹配:即不能多也不能少,多或者少都会抛出ValueError错误,所以,只需要补全所有的列标题名即可

但是在查看csv文件后,发现列数与names参数个数完全一致,请问您有这个问题吗?

mh739025250 commented 3 years ago

我的确没遇到这个问题。 你可以把具体的报错贴出来?看一下是哪个文件的问题

aaawu commented 3 years ago

感谢您的回复!报错如下

data_process.py:74: ParserWarning: Falling back to the 'python' engine because the 'c' engine does not support regex separators (separators > 1 char and different from '\s+' are interpreted as regex); you can avoid this warning by specifying engine='python'. df = pd.read_csv(filename, header=0, names=names, sep=r",\s+")

------以上是warning 不影响------ Traceback (most recent call last): File "data_process.py", line 133, in arr = convert_csv_to_arr("adult.test.csv", mean_std) File "data_process.py", line 88, in convert_csv_to_arr df = load_csv(filename) File "data_process.py", line 74, in load_csv df = pd.read_csv(filename, header=0, names=names, sep=r",\s+") File "/home/r7/.local/lib/python3.6/site-packages/pandas/io/parsers.py", line 688, in read_csv return _read(filepath_or_buffer, kwds) File "/home/r7/.local/lib/python3.6/site-packages/pandas/io/parsers.py", line 454, in _read parser = TextFileReader(fp_or_buf, kwds) File "/home/r7/.local/lib/python3.6/site-packages/pandas/io/parsers.py", line 948, in init self._make_engine(self.engine) File "/home/r7/.local/lib/python3.6/site-packages/pandas/io/parsers.py", line 1191, in _make_engine self._engine = klass(self.f, self.options) File "/home/r7/.local/lib/python3.6/site-packages/pandas/io/parsers.py", line 2407, in init ) = self._infer_columns() File "/home/r7/.local/lib/python3.6/site-packages/pandas/io/parsers.py", line 2768, in _infer_columns "Number of passed names did not match " ValueError: Number of passed names did not match number of header fields in the file

我尝试换了电脑 也尝试重新安装了pandas库 都没能成功

mh739025250 commented 3 years ago

是不是adult.text.csv开头多了一行|1x3 Cross validator? 你可以看一下,也许是这个问题

wuzh3nq1 commented 2 years ago

我一开始也是这个问题,用excel打开csv文件都会这样,重新下载文件之后用记事本打开编辑就没报错了,不知道什么原因