January 23rd, 2019
import pandas
data = pandas.read_csv('Twitter-sentiment-self-drive-DFE.csv',
encoding = "ISO-8859-1")
head(py$data)
## _unit_id _golden _unit_state _trusted_judgments _last_judgment_at ## 1 724227031 TRUE golden 236 NaN ## 2 724227032 TRUE golden 231 NaN ## 3 724227033 TRUE golden 233 NaN ## 4 724227034 TRUE golden 240 NaN ## 5 724227035 TRUE golden 240 NaN ## 6 724227036 TRUE golden 241 NaN ## sentiment sentiment:confidence our_id sentiment_gold ## 1 5 0.7579 10001 5\n4 ## 2 5 0.8775 10002 5\n4 ## 3 2 0.6805 10003 2\n1 ## 4 2 0.8820 10004 2\n1 ## 5 3 1.0000 10005 3 ## 6 3 1.0000 10006 3 ## sentiment_gold_reason ## 1 Author is excited about the development of the technology. ## 2 Author is excited that driverless cars will benefit the disabled. ## 3 The author is skeptical of the safety and reliability of a driverless car. ## 4 The author is skeptical of the project's value. ## 5 Author is making an observation without expressing an opinion. ## 6 Author is asking a question without expressing an opinion. ## text ## 1 Two places I'd invest all my money if I could: 3D printing and Self-driving cars!!! ## 2 Awesome! Google driverless cars will help the blind travel more often; https://t.co/QWuXR0FrBpv ## 3 If Google maps can't keep up with road construction, how am I supposed to trust a driverless car to get around here? ## 4 Autonomous cars seem way overhyped given the technology challenges; pilotless planes seem much more doable and needed. ## 5 Just saw Google self-driving car on I-34. It was painted green and blue. ## 6 Will driverless cars eventually replace taxi drivers in cities?
print(data.columns)
## Index([u'_unit_id', u'_golden', u'_unit_state', u'_trusted_judgments', ## u'_last_judgment_at', u'sentiment', u'sentiment:confidence', u'our_id', ## u'sentiment_gold', u'sentiment_gold_reason', u'text'], ## dtype='object')
colnames(py$data)
## [1] "_unit_id" "_golden" ## [3] "_unit_state" "_trusted_judgments" ## [5] "_last_judgment_at" "sentiment" ## [7] "sentiment:confidence" "our_id" ## [9] "sentiment_gold" "sentiment_gold_reason" ## [11] "text"
print(data['sentiment'].head())
## 0 5 ## 1 5 ## 2 2 ## 3 2 ## 4 3 ## Name: sentiment, dtype: object
head(py$data$sentiment)
## [1] "5" "5" "2" "2" "3" "3"
Can also write like this:
head(py$data[,"sentiment"])
## [1] "5" "5" "2" "2" "3" "3"