-1

I would like to choose the rows and columns under condition, for example:

0 is camera, 1 is video. when the column == 1, return the data of video. else return the data of photo

The purpose is to get separate data based on video and photo.

The code shows below. I guess the problem is from loc.[i, :] because when I changed i to 0, it grab the first row successfully. But don't know why i doesn't work.

for i in range(len(dataset)):

    if dataset['status_type_num'][i] == 1:

        video_data = dataset[['num_reactions', 'num_comments', 'num_shares', 'num_likes', 'num_loves']].loc[i, :]
print(video_data)

I expect output would be the data from 5 columns('num_reactions', 'num_comments', 'num_shares', 'num_likes', 'num_loves') of video.

Thank you.

EdChum
  • 376,765
  • 198
  • 813
  • 562
Jeffvc
  • 3
  • 1

1 Answers1

0

Subset the dataset.

Example:

Df_Camera = Dataset[(Dataset['status_type_num'] == 0)]
Df_Video = Dataset[(Dataset['status_type_num'] == 1)]
PyRar
  • 539
  • 1
  • 4
  • 21