Skip to content

video_df = video_df.append(video_data, ignore_index=True) comments_df = comments_df.append(comments_data, ignore_index=True) #5

Description

@AbuthahirGitHub

When I use in Google Colab notebook I faced this error in ##Get video statistics for all the channels

Getting video information from channel: Mr. KK - கதை கந்தசாமி

AttributeError Traceback (most recent call last)
in <cell line: 6>()
15
16 # append video data together and comment data toghether
---> 17 video_df = video_df.append(video_data, ignore_index=True)
18 comments_df = comments_df.append(comments_data, ignore_index=True)

/usr/local/lib/python3.10/dist-packages/pandas/core/generic.py in getattr(self, name)
5987 ):
5988 return self[name]
-> 5989 return object.getattribute(self, name)
5990
5991 def setattr(self, name: str, value) -> None:

AttributeError: 'DataFrame' object has no attribute 'append'

Solution is change append to concat

###Original Code

Create a dataframe with video statistics and comments from all channels

video_df = pd.DataFrame()
comments_df = pd.DataFrame()

for c in channel_data['channelName'].unique():
print("Getting video information from channel: " + c)
playlist_id = channel_data.loc[channel_data['channelName']== c, 'playlistId'].iloc[0]
video_ids = get_video_ids(youtube, playlist_id)

# get video data
video_data = get_video_details(youtube, video_ids)
# get comment data
comments_data = get_comments_in_videos(youtube, video_ids)

# append video data together and comment data toghether
video_df = video_df.append(video_data, ignore_index=True)
comments_df = comments_df.append(comments_data, ignore_index=True)

###Replace with

Create a dataframe with video statistics and comments from all channels

video_df = pd.DataFrame()
comments_df = pd.DataFrame()

for c in channel_data['channelName'].unique():
print("Getting video information from channel: " + c)
playlist_id = channel_data.loc[channel_data['channelName']== c, 'playlistId'].iloc[0]
video_ids = get_video_ids(youtube, playlist_id)

# get video data
video_data = get_video_details(youtube, video_ids)
# get comment data
comments_data = get_comments_in_videos(youtube, video_ids)

# append video data together and comment data toghether
video_df = video_df.concat(video_data, ignore_index=True)
comments_df = comments_df.concat(comments_data, ignore_index=True)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions