使用 google.colab 导入文件的 google 协作中的协作者无法使用数据
Data unavailable to Collaborators on google collab using google.colab import files
我们有 4 个人在 google Colaboratory 的 Ipyothon 笔记本上工作。我能够为自己上传文件。但它对其他用户不可用。它会为他们生成一条错误消息。它识别我上传的文件。如果有人能以一种巧妙的方式帮助解决这个问题,那就太好了。似乎是 Colaboratory 的一个非常基本的功能。
enter code here`from google.colab import files
uploaded = files.upload()
## Checks the files uploaded
for fn in uploaded.keys():
print('User uploaded file "{name}" with length {length} bytes'.format(name=fn,
length=len(uploaded[fn])))
import pandas as pd
my_file = pd.read_csv("data_assignment1.csv")
print(my_file.head())
出现以下错误:
FileNotFoundError Traceback (most recent call last)
<ipython-input-2-06e7ca74a847> in <module>()
1 import pandas as pd
----> 2 my_file = pd.read_csv("data_assignment1.csv")
3 print(my_file.head())
/usr/local/lib/python3.6/dist-packages/pandas/io/parsers.py in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, escapechar, comment, encoding, dialect, tupleize_cols, error_bad_lines, warn_bad_lines, skipfooter, skip_footer, doublequote, delim_whitespace, as_recarray, compact_ints, use_unsigned, low_memory, buffer_lines, memory_map, float_precision)
707 skip_blank_lines=skip_blank_lines)
708
--> 709 return _read(filepath_or_buffer, kwds)
710
711 parser_f.__name__ = name
/usr/local/lib/python3.6/dist-packages/pandas/io/parsers.py in _read(filepath_or_buffer, kwds)
447
448 # Create the parser.
--> 449 parser = TextFileReader(filepath_or_buffer, **kwds)
450
451 if chunksize or iterator:
/usr/local/lib/python3.6/dist-packages/pandas/io/parsers.py in __init__(self, f, engine, **kwds)
816 self.options['has_index_names'] = kwds['has_index_names']
817
--> 818 self._make_engine(self.engine)
819
820 def close(self):
/usr/local/lib/python3.6/dist-packages/pandas/io/parsers.py in _make_engine(self, engine)
1047 def _make_engine(self, engine='c'):
1048 if engine == 'c':
-> 1049 self._engine = CParserWrapper(self.f, **self.options)
1050 else:
1051 if engine == 'python':
/usr/local/lib/python3.6/dist-packages/pandas/io/parsers.py in __init__(self, src, **kwds)
1693 kwds['allow_leading_cols'] = self.index_col is not False
1694
-> 1695 self._reader = parsers.TextReader(src, **kwds)
1696
1697 # XXX
pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader.__cinit__()
pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._setup_parser_source()
FileNotFoundError: File b'data_assignment1.csv' does not exist
原因是,虽然笔记本是在协作者之间共享的,但机器实例是为他们每个人创建的。因此,当您上传数据时,您的合作者将看不到它,因为它在不同的机器上。所以你可以
- 让他们从他们的本地计算机为他们每个人再次上传。
- 更改为通过
wget
或 git
或 Google 驱动器加载数据,其中每个驱动器将重复下载。不过,他们不需要通过本地计算机上传数据。
我们有 4 个人在 google Colaboratory 的 Ipyothon 笔记本上工作。我能够为自己上传文件。但它对其他用户不可用。它会为他们生成一条错误消息。它识别我上传的文件。如果有人能以一种巧妙的方式帮助解决这个问题,那就太好了。似乎是 Colaboratory 的一个非常基本的功能。
enter code here`from google.colab import files
uploaded = files.upload()
## Checks the files uploaded
for fn in uploaded.keys():
print('User uploaded file "{name}" with length {length} bytes'.format(name=fn,
length=len(uploaded[fn])))
import pandas as pd
my_file = pd.read_csv("data_assignment1.csv")
print(my_file.head())
出现以下错误:
FileNotFoundError Traceback (most recent call last)
<ipython-input-2-06e7ca74a847> in <module>()
1 import pandas as pd
----> 2 my_file = pd.read_csv("data_assignment1.csv")
3 print(my_file.head())
/usr/local/lib/python3.6/dist-packages/pandas/io/parsers.py in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, escapechar, comment, encoding, dialect, tupleize_cols, error_bad_lines, warn_bad_lines, skipfooter, skip_footer, doublequote, delim_whitespace, as_recarray, compact_ints, use_unsigned, low_memory, buffer_lines, memory_map, float_precision)
707 skip_blank_lines=skip_blank_lines)
708
--> 709 return _read(filepath_or_buffer, kwds)
710
711 parser_f.__name__ = name
/usr/local/lib/python3.6/dist-packages/pandas/io/parsers.py in _read(filepath_or_buffer, kwds)
447
448 # Create the parser.
--> 449 parser = TextFileReader(filepath_or_buffer, **kwds)
450
451 if chunksize or iterator:
/usr/local/lib/python3.6/dist-packages/pandas/io/parsers.py in __init__(self, f, engine, **kwds)
816 self.options['has_index_names'] = kwds['has_index_names']
817
--> 818 self._make_engine(self.engine)
819
820 def close(self):
/usr/local/lib/python3.6/dist-packages/pandas/io/parsers.py in _make_engine(self, engine)
1047 def _make_engine(self, engine='c'):
1048 if engine == 'c':
-> 1049 self._engine = CParserWrapper(self.f, **self.options)
1050 else:
1051 if engine == 'python':
/usr/local/lib/python3.6/dist-packages/pandas/io/parsers.py in __init__(self, src, **kwds)
1693 kwds['allow_leading_cols'] = self.index_col is not False
1694
-> 1695 self._reader = parsers.TextReader(src, **kwds)
1696
1697 # XXX
pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader.__cinit__()
pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._setup_parser_source()
FileNotFoundError: File b'data_assignment1.csv' does not exist
原因是,虽然笔记本是在协作者之间共享的,但机器实例是为他们每个人创建的。因此,当您上传数据时,您的合作者将看不到它,因为它在不同的机器上。所以你可以
- 让他们从他们的本地计算机为他们每个人再次上传。
- 更改为通过
wget
或git
或 Google 驱动器加载数据,其中每个驱动器将重复下载。不过,他们不需要通过本地计算机上传数据。