Question: Hello, I need help with the following please. This is in Python I need to grab just the user data and use a generator to
Hello,
I need help with the following please.
This is in Python
I need to grab just the user data and use a generator to yield just the user data and put it into a Pandas Dataframe. This is what I have but it isn't in the dataframe the way it should be. How can I do this?
Thank you



'user': {'contributors_enabled': false, 'created_at': 'Sat May 30 02:52:37 +0000 2020', "default_profile': True, "default_profile_image': False, 'description': '#climate #ecology #environment #coronavirus' '#antifascist #water #ocean #forest #indigenous' '#renewable #wildlife #humanrights #protest #AI #ESG' '#space #science', 'entities': {'description': {'urls': []}, 'url': {'urls': [{'display_url': 'eijump.org', 'expanded_url': 'https://eijump.org/', 'indices': [0, 23), 'url': 'https://t.co/9vNXsZfVTz'}]}}, 'favourites_count': 1702, 'follow_request_sent': None, 'followers_count': 477, 'following': None, 'friends_count': 2126, 'geo_enabled': false, "has_extended_profile': True, 'id': 1266563068223504389, "id_str': '1266563068223504389', 'is_translation_enabled': false, "is_translator': false, 'lang': None, "listed_count": 3, "location': 'New York, USA', 'name': 'Bearing Witness for Ecology etc', 'notifications': None, 'profile_background_color': 'F5F8FA', 'profile_background_image_url': None, 'profile_background_image_url_https': None, 'profile_background_tile': false, 'profile_banner_url': 'https://pbs.twimg.com/profile_banners/1266563068223504389/1591998866', 'profile_image_url': 'http://pbs.twimg.com/profile_images/1271561255338348544/axYYPpzx_normal.jpg', 'profile_image_url_https': 'https://pbs. twimg.com/profile_images/1271561255338348544/axYYPpzx_normal.jpg', 'profile_image_url_https': 'https://pbs.twimg.com/profile_images/1271561255338348544/axYYPpzx_normal.jpg', 'profile_link_color': '1DA1F2', 'profile_sidebar_border_color': 'CODEED', 'profile_sidebar_fill_color': 'DDEEF6', 'profile_text_color': '333333', 'profile_use_background_image': True, 'protected': false, 'screen_name': 'ecobearwitness', 'statuses_count': 24503, "time_zone': None, 'translator_type': 'none', 'url': 'https://t.co/9vNXsZfVTz', 'utc_offset': None, 'verified': False}}, {'contributors': None, 'coordinates': None, "created_at': 'Thu Jan 28 01:41:51 +0000 2021', 'entities': {'hashtags': [], Q4 (1.5 point) Complete following tweet_user_generator. Generator should yield only user value from a tweet In [67]: def tweet_user_generator(tweets): for tweet in tweets: user_tweet = {} user_tweet['user'] = tweet['user'] yield user_tweet In [70]: user_df = pd. DataFrame (tweet_user_generator (tweets)) In [71]: user_df Out [71]: user 0 'id': 1133109970197573634, 'id str': '1133109... 1 ('id': 77299934, 'id_str': '77299934', 'name':... 2 {"id": 1351266127083692033, 'id_str': '1351266... 3 ('id': 4885435445, 'id_str': '4885435445', 'na... 4 ('id': 1623308912, 'id_str': '1623308912', 'na... 9912 {"id": 27669037, 'id_str': '27669037', 'name'... 9913 {'id: 1107009017761665024, 'id_str': '1107009. 'user': {'contributors_enabled': false, 'created_at': 'Sat May 30 02:52:37 +0000 2020', "default_profile': True, "default_profile_image': False, 'description': '#climate #ecology #environment #coronavirus' '#antifascist #water #ocean #forest #indigenous' '#renewable #wildlife #humanrights #protest #AI #ESG' '#space #science', 'entities': {'description': {'urls': []}, 'url': {'urls': [{'display_url': 'eijump.org', 'expanded_url': 'https://eijump.org/', 'indices': [0, 23), 'url': 'https://t.co/9vNXsZfVTz'}]}}, 'favourites_count': 1702, 'follow_request_sent': None, 'followers_count': 477, 'following': None, 'friends_count': 2126, 'geo_enabled': false, "has_extended_profile': True, 'id': 1266563068223504389, "id_str': '1266563068223504389', 'is_translation_enabled': false, "is_translator': false, 'lang': None, "listed_count": 3, "location': 'New York, USA', 'name': 'Bearing Witness for Ecology etc', 'notifications': None, 'profile_background_color': 'F5F8FA', 'profile_background_image_url': None, 'profile_background_image_url_https': None, 'profile_background_tile': false, 'profile_banner_url': 'https://pbs.twimg.com/profile_banners/1266563068223504389/1591998866', 'profile_image_url': 'http://pbs.twimg.com/profile_images/1271561255338348544/axYYPpzx_normal.jpg', 'profile_image_url_https': 'https://pbs. twimg.com/profile_images/1271561255338348544/axYYPpzx_normal.jpg', 'profile_image_url_https': 'https://pbs.twimg.com/profile_images/1271561255338348544/axYYPpzx_normal.jpg', 'profile_link_color': '1DA1F2', 'profile_sidebar_border_color': 'CODEED', 'profile_sidebar_fill_color': 'DDEEF6', 'profile_text_color': '333333', 'profile_use_background_image': True, 'protected': false, 'screen_name': 'ecobearwitness', 'statuses_count': 24503, "time_zone': None, 'translator_type': 'none', 'url': 'https://t.co/9vNXsZfVTz', 'utc_offset': None, 'verified': False}}, {'contributors': None, 'coordinates': None, "created_at': 'Thu Jan 28 01:41:51 +0000 2021', 'entities': {'hashtags': [], Q4 (1.5 point) Complete following tweet_user_generator. Generator should yield only user value from a tweet In [67]: def tweet_user_generator(tweets): for tweet in tweets: user_tweet = {} user_tweet['user'] = tweet['user'] yield user_tweet In [70]: user_df = pd. DataFrame (tweet_user_generator (tweets)) In [71]: user_df Out [71]: user 0 'id': 1133109970197573634, 'id str': '1133109... 1 ('id': 77299934, 'id_str': '77299934', 'name':... 2 {"id": 1351266127083692033, 'id_str': '1351266... 3 ('id': 4885435445, 'id_str': '4885435445', 'na... 4 ('id': 1623308912, 'id_str': '1623308912', 'na... 9912 {"id": 27669037, 'id_str': '27669037', 'name'... 9913 {'id: 1107009017761665024, 'id_str': '1107009
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
