Bentley University, Spring 2019 CS 230
Python5代写 A hashtag is any word in a Tweet that begins with a # symbol, a mention is any word in a Tweet that begins with an @ symbol.
Introduction to Programming with Python
Homework 6 – Twitter Analytics
A hashtag is any word in a Tweet that begins with a # symbol, a mention is any word in a Tweet that begins with an @ symbol. In this assignment, you will use the pandas, numpy, and matplotlib modules to analyze hashtags or mentions on Twitter.
Export Your Tweets Python5代写
You can use the sample Twitter data file supplied containing Tweets from the cisSandbox account or export your own Tweets to analyze. Follow these steps to export your own Tweets:
Sign in to your Twitter account.
- Click your profile icon at the top right corner of the page.
- Click Analytics from the dropdown menu below your profile icon.
- On the Analytics page, click Tweets at the top of the page
- Select a date range of activity (choose a large enough daterange so you have Tweets containing several hashtags or mentions),
5.Click the Export Data button to export your Twitter Python5代写
6.Save the file as tweets.csv in the folder with the python program you are about to
Analyze Your Tweets
- Follow the example given in class to load Twitter data from the tweets.csv file into apandas DataFrame, removing irrelevant
- Allow the user to specify whether to analyze hashtags or mentions by typing h or
- Analyze the Tweet text column of the data frame to create a dictionary of hashtags/mentions and corresponding frequencies (number of times each appears). For simplicity, the DataFrame will have two columns: Hashtag and Frequency, regardlessof whether you are analyzing hashtags or mentions. As you process the data, convert all words to lower case (so that #BENTLEY and #bentley will be considered the same word.Python5代写
- Create a pandas DataFrame containing each hashtag and its corresponding
- Print the
- Sort the DataFrame alphabetically by hashtag. Print the sorted
- Sort the DataFrame in decreasing order by frequency. Print the sorted
- Create a horizontal bar chart that plots each hashtag and its frequency. Be sure to set x and y labels for the axes, ticks for values and hashtags, and a title for your
See https://matplotlib.org/gallery/lines_bars_and_markers/barh.html or https://medium.com/python-pandemonium/data-visualization-in-python-bar-graph-in- matplotlib-f1738602e9c4 for examples of how to create a horizontal bar chart.
Sample Output Python5代写
Analyze [H]ashtags or [M]entions?h Hashtag Frequency
- #bentley2022 6
- #ohbot 1
- #teslatuesday 1 Python5代写
- #tiltbrush 3
- #bentley2022 6
- #ohbot 1
- #teslatuesday 1
- #tiltbrush 3
Sorted Descending by Frequency Hashtag FrequencyPython5代写
Analyze [H]ashtags or [M]entions?mPython5代写
- @cissandbox 14
- @glarsbentleyu 2
- @bentleyu 11
- @cissandbox). 1
- @_connerc 1
- @mendix 7
- @bentleyalumni 1
- @amazonrobotics 1
- @poly 3
- @bentleyfalcons 1
Sorted Descending by Frequency Python5代写
- This assignment will be worth 8 percent of your final
- The input and output of your program need to appear in exactly the order that is shownin the sample interaction
- Your program should compile without syntax errors to receive any credit. If a part of your program is working, you will receive partial credit, but only if the program compiles without syntax errors. As you program, I highly recommend that you save intermediate versions of the .py file each time you get a piece of the program running. This way youcan always have something to submit that works on at least some of the
This problem has several tasks. Complete as many as you can, or all of them for full credit.
|Task Points Python5代写|
|Loading the .csv file||3|
|Creation of a dictionary of hashtags||7|
|Converting words to lower case||2|
|Creation of a pandas DataFrame||3|
|Printing the DataFrame Python5代写||2|
|Sorting and printing the sorted DataFrame||8|
|Creating the bar chart||10|
|Code style, readability, comments, approach||5|
- Name your script as py and upload it onto the Blackboard by thedeadline.