Skip to content

Commit 7fc9782

Browse files
Missing sample when loading csv file (#1708)
When reading a file with the ``read_csv`` method, by default the first line of the file is assumed to contain header information. In the example file mentioned in the tutorial, the first line contains data and if the ``names`` attribute of the ``read_csv`` method is not informed, the first line will be considered as a header. This way, when loading the dataset the first sample will be lost. Co-authored-by: Holly Sweeney <77758406+holly1238@users.noreply.github.com>
1 parent 281f370 commit 7fc9782

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

beginner_source/basics/data_tutorial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def __getitem__(self, idx):
160160

161161

162162
def __init__(self, annotations_file, img_dir, transform=None, target_transform=None):
163-
self.img_labels = pd.read_csv(annotations_file)
163+
self.img_labels = pd.read_csv(annotations_file, names=['file_name', 'label'])
164164
self.img_dir = img_dir
165165
self.transform = transform
166166
self.target_transform = target_transform

0 commit comments

Comments
 (0)