Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "cells": [
- {
- "cell_type": "code",
- "execution_count": 1,
- "metadata": {},
- "outputs": [],
- "source": [
- "import pandas as pd\n",
- "import xml.etree.ElementTree as ET"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 2,
- "metadata": {},
- "outputs": [],
- "source": [
- "path_train = r'C:\\Users\\Kyuyeon Rhee\\myworks\\laptop2\\sentiment\\ABSA16_Laptops_Train_SB1_v2.xml'\n",
- "\n",
- "def get_list(path):\n",
- " tree = ET.parse(path)\n",
- " root = tree.getroot()\n",
- " text_list = []\n",
- " opinion_list = []\n",
- " for review in root.findall('Review'):\n",
- " str_text = \"\"\n",
- " opinion_inner_list = []\n",
- " for sent in review.findall('./sentences/sentence'):\n",
- " str_text = str_text + sent.find('text').text\n",
- " text_list.append(str_text)\n",
- " for opinion in review.findall('./sentences/sentence/Opinions/Opinion'):\n",
- " opinion_dict = {opinion.get('category').replace('#','_'): opinion.get('polarity')}\n",
- " opinion_inner_list.append(opinion_dict)\n",
- " opinion_list.append(opinion_inner_list)\n",
- " return text_list,opinion_list"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 3,
- "metadata": {},
- "outputs": [],
- "source": [
- "train_text_list, train_opinion_list = get_list(path_train)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 4,
- "metadata": {},
- "outputs": [],
- "source": [
- "df1 = pd.DataFrame(data = train_text_list, columns = ['text'])\n",
- "df2 = pd.DataFrame(data = train_opinion_list)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 5,
- "metadata": {
- "scrolled": true
- },
- "outputs": [
- {
- "data": {
- "text/html": [
- "<div>\n",
- "<style scoped>\n",
- " .dataframe tbody tr th:only-of-type {\n",
- " vertical-align: middle;\n",
- " }\n",
- "\n",
- " .dataframe tbody tr th {\n",
- " vertical-align: top;\n",
- " }\n",
- "\n",
- " .dataframe thead th {\n",
- " text-align: right;\n",
- " }\n",
- "</style>\n",
- "<table border=\"1\" class=\"dataframe\">\n",
- " <thead>\n",
- " <tr style=\"text-align: right;\">\n",
- " <th></th>\n",
- " <th>text</th>\n",
- " </tr>\n",
- " </thead>\n",
- " <tbody>\n",
- " <tr>\n",
- " <th>0</th>\n",
- " <td>Being a PC user my whole life....This computer...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>1</th>\n",
- " <td>the laptop was really good and it goes really ...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>2</th>\n",
- " <td>As a lifelong Windows user, I was extremely pl...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3</th>\n",
- " <td>Oh my goodness-I am not a happy camper.My HP i...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>4</th>\n",
- " <td>Since I purchased my Toshiba netbook, I have b...</td>\n",
- " </tr>\n",
- " </tbody>\n",
- "</table>\n",
- "</div>"
- ],
- "text/plain": [
- " text\n",
- "0 Being a PC user my whole life....This computer...\n",
- "1 the laptop was really good and it goes really ...\n",
- "2 As a lifelong Windows user, I was extremely pl...\n",
- "3 Oh my goodness-I am not a happy camper.My HP i...\n",
- "4 Since I purchased my Toshiba netbook, I have b..."
- ]
- },
- "execution_count": 5,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "df1.head()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 6,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "<div>\n",
- "<style scoped>\n",
- " .dataframe tbody tr th:only-of-type {\n",
- " vertical-align: middle;\n",
- " }\n",
- "\n",
- " .dataframe tbody tr th {\n",
- " vertical-align: top;\n",
- " }\n",
- "\n",
- " .dataframe thead th {\n",
- " text-align: right;\n",
- " }\n",
- "</style>\n",
- "<table border=\"1\" class=\"dataframe\">\n",
- " <thead>\n",
- " <tr style=\"text-align: right;\">\n",
- " <th></th>\n",
- " <th>0</th>\n",
- " <th>1</th>\n",
- " <th>2</th>\n",
- " <th>3</th>\n",
- " <th>4</th>\n",
- " <th>5</th>\n",
- " <th>6</th>\n",
- " <th>7</th>\n",
- " <th>8</th>\n",
- " <th>9</th>\n",
- " <th>...</th>\n",
- " <th>15</th>\n",
- " <th>16</th>\n",
- " <th>17</th>\n",
- " <th>18</th>\n",
- " <th>19</th>\n",
- " <th>20</th>\n",
- " <th>21</th>\n",
- " <th>22</th>\n",
- " <th>23</th>\n",
- " <th>24</th>\n",
- " </tr>\n",
- " </thead>\n",
- " <tbody>\n",
- " <tr>\n",
- " <th>0</th>\n",
- " <td>{'LAPTOP_GENERAL': 'positive'}</td>\n",
- " <td>{'BATTERY_OPERATION_PERFORMANCE': 'positive'}</td>\n",
- " <td>{'CPU_OPERATION_PERFORMANCE': 'positive'}</td>\n",
- " <td>{'GRAPHICS_GENERAL': 'positive'}</td>\n",
- " <td>{'HARD_DISC_DESIGN_FEATURES': 'positive'}</td>\n",
- " <td>{'LAPTOP_OPERATION_PERFORMANCE': 'positive'}</td>\n",
- " <td>{'LAPTOP_USABILITY': 'positive'}</td>\n",
- " <td>{'LAPTOP_USABILITY': 'positive'}</td>\n",
- " <td>{'LAPTOP_PORTABILITY': 'positive'}</td>\n",
- " <td>{'CPU_OPERATION_PERFORMANCE': 'positive'}</td>\n",
- " <td>...</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>1</th>\n",
- " <td>{'LAPTOP_GENERAL': 'positive'}</td>\n",
- " <td>{'LAPTOP_OPERATION_PERFORMANCE': 'positive'}</td>\n",
- " <td>{'LAPTOP_GENERAL': 'positive'}</td>\n",
- " <td>{'LAPTOP_PRICE': 'positive'}</td>\n",
- " <td>{'LAPTOP_GENERAL': 'positive'}</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>...</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>2</th>\n",
- " <td>{'LAPTOP_PORTABILITY': 'positive'}</td>\n",
- " <td>{'LAPTOP_QUALITY': 'positive'}</td>\n",
- " <td>{'LAPTOP_USABILITY': 'positive'}</td>\n",
- " <td>{'LAPTOP_DESIGN_FEATURES': 'positive'}</td>\n",
- " <td>{'LAPTOP_PORTABILITY': 'positive'}</td>\n",
- " <td>{'LAPTOP_MISCELLANEOUS': 'positive'}</td>\n",
- " <td>{'LAPTOP_MISCELLANEOUS': 'positive'}</td>\n",
- " <td>{'LAPTOP_QUALITY': 'positive'}</td>\n",
- " <td>{'OS_DESIGN_FEATURES': 'positive'}</td>\n",
- " <td>None</td>\n",
- " <td>...</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3</th>\n",
- " <td>{'LAPTOP_GENERAL': 'negative'}</td>\n",
- " <td>{'LAPTOP_DESIGN_FEATURES': 'negative'}</td>\n",
- " <td>{'LAPTOP_PORTABILITY': 'negative'}</td>\n",
- " <td>{'BATTERY_QUALITY': 'negative'}</td>\n",
- " <td>{'BATTERY_OPERATION_PERFORMANCE': 'negative'}</td>\n",
- " <td>{'BATTERY_QUALITY': 'negative'}</td>\n",
- " <td>{'SUPPORT_QUALITY': 'negative'}</td>\n",
- " <td>{'SUPPORT_QUALITY': 'negative'}</td>\n",
- " <td>{'SUPPORT_QUALITY': 'negative'}</td>\n",
- " <td>{'LAPTOP_GENERAL': 'negative'}</td>\n",
- " <td>...</td>\n",
- " <td>{'COMPANY_GENERAL': 'negative'}</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>4</th>\n",
- " <td>{'LAPTOP_GENERAL': 'positive'}</td>\n",
- " <td>{'LAPTOP_PORTABILITY': 'positive'}</td>\n",
- " <td>{'DISPLAY_USABILITY': 'neutral'}</td>\n",
- " <td>{'DISPLAY_DESIGN_FEATURES': 'neutral'}</td>\n",
- " <td>{'LAPTOP_GENERAL': 'positive'}</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>...</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " </tr>\n",
- " </tbody>\n",
- "</table>\n",
- "<p>5 rows × 25 columns</p>\n",
- "</div>"
- ],
- "text/plain": [
- " 0 \\\n",
- "0 {'LAPTOP_GENERAL': 'positive'} \n",
- "1 {'LAPTOP_GENERAL': 'positive'} \n",
- "2 {'LAPTOP_PORTABILITY': 'positive'} \n",
- "3 {'LAPTOP_GENERAL': 'negative'} \n",
- "4 {'LAPTOP_GENERAL': 'positive'} \n",
- "\n",
- " 1 \\\n",
- "0 {'BATTERY_OPERATION_PERFORMANCE': 'positive'} \n",
- "1 {'LAPTOP_OPERATION_PERFORMANCE': 'positive'} \n",
- "2 {'LAPTOP_QUALITY': 'positive'} \n",
- "3 {'LAPTOP_DESIGN_FEATURES': 'negative'} \n",
- "4 {'LAPTOP_PORTABILITY': 'positive'} \n",
- "\n",
- " 2 \\\n",
- "0 {'CPU_OPERATION_PERFORMANCE': 'positive'} \n",
- "1 {'LAPTOP_GENERAL': 'positive'} \n",
- "2 {'LAPTOP_USABILITY': 'positive'} \n",
- "3 {'LAPTOP_PORTABILITY': 'negative'} \n",
- "4 {'DISPLAY_USABILITY': 'neutral'} \n",
- "\n",
- " 3 \\\n",
- "0 {'GRAPHICS_GENERAL': 'positive'} \n",
- "1 {'LAPTOP_PRICE': 'positive'} \n",
- "2 {'LAPTOP_DESIGN_FEATURES': 'positive'} \n",
- "3 {'BATTERY_QUALITY': 'negative'} \n",
- "4 {'DISPLAY_DESIGN_FEATURES': 'neutral'} \n",
- "\n",
- " 4 \\\n",
- "0 {'HARD_DISC_DESIGN_FEATURES': 'positive'} \n",
- "1 {'LAPTOP_GENERAL': 'positive'} \n",
- "2 {'LAPTOP_PORTABILITY': 'positive'} \n",
- "3 {'BATTERY_OPERATION_PERFORMANCE': 'negative'} \n",
- "4 {'LAPTOP_GENERAL': 'positive'} \n",
- "\n",
- " 5 \\\n",
- "0 {'LAPTOP_OPERATION_PERFORMANCE': 'positive'} \n",
- "1 None \n",
- "2 {'LAPTOP_MISCELLANEOUS': 'positive'} \n",
- "3 {'BATTERY_QUALITY': 'negative'} \n",
- "4 None \n",
- "\n",
- " 6 7 \\\n",
- "0 {'LAPTOP_USABILITY': 'positive'} {'LAPTOP_USABILITY': 'positive'} \n",
- "1 None None \n",
- "2 {'LAPTOP_MISCELLANEOUS': 'positive'} {'LAPTOP_QUALITY': 'positive'} \n",
- "3 {'SUPPORT_QUALITY': 'negative'} {'SUPPORT_QUALITY': 'negative'} \n",
- "4 None None \n",
- "\n",
- " 8 \\\n",
- "0 {'LAPTOP_PORTABILITY': 'positive'} \n",
- "1 None \n",
- "2 {'OS_DESIGN_FEATURES': 'positive'} \n",
- "3 {'SUPPORT_QUALITY': 'negative'} \n",
- "4 None \n",
- "\n",
- " 9 ... \\\n",
- "0 {'CPU_OPERATION_PERFORMANCE': 'positive'} ... \n",
- "1 None ... \n",
- "2 None ... \n",
- "3 {'LAPTOP_GENERAL': 'negative'} ... \n",
- "4 None ... \n",
- "\n",
- " 15 16 17 18 19 20 21 22 \\\n",
- "0 None None None None None None None None \n",
- "1 None None None None None None None None \n",
- "2 None None None None None None None None \n",
- "3 {'COMPANY_GENERAL': 'negative'} None None None None None None None \n",
- "4 None None None None None None None None \n",
- "\n",
- " 23 24 \n",
- "0 None None \n",
- "1 None None \n",
- "2 None None \n",
- "3 None None \n",
- "4 None None \n",
- "\n",
- "[5 rows x 25 columns]"
- ]
- },
- "execution_count": 6,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "df2.head()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 8,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "<div>\n",
- "<style scoped>\n",
- " .dataframe tbody tr th:only-of-type {\n",
- " vertical-align: middle;\n",
- " }\n",
- "\n",
- " .dataframe tbody tr th {\n",
- " vertical-align: top;\n",
- " }\n",
- "\n",
- " .dataframe thead th {\n",
- " text-align: right;\n",
- " }\n",
- "</style>\n",
- "<table border=\"1\" class=\"dataframe\">\n",
- " <thead>\n",
- " <tr style=\"text-align: right;\">\n",
- " <th></th>\n",
- " <th>text</th>\n",
- " <th>0</th>\n",
- " <th>1</th>\n",
- " <th>2</th>\n",
- " <th>3</th>\n",
- " <th>4</th>\n",
- " <th>5</th>\n",
- " <th>6</th>\n",
- " <th>7</th>\n",
- " <th>8</th>\n",
- " <th>...</th>\n",
- " <th>15</th>\n",
- " <th>16</th>\n",
- " <th>17</th>\n",
- " <th>18</th>\n",
- " <th>19</th>\n",
- " <th>20</th>\n",
- " <th>21</th>\n",
- " <th>22</th>\n",
- " <th>23</th>\n",
- " <th>24</th>\n",
- " </tr>\n",
- " </thead>\n",
- " <tbody>\n",
- " <tr>\n",
- " <th>0</th>\n",
- " <td>Being a PC user my whole life....This computer...</td>\n",
- " <td>{'LAPTOP_GENERAL': 'positive'}</td>\n",
- " <td>{'BATTERY_OPERATION_PERFORMANCE': 'positive'}</td>\n",
- " <td>{'CPU_OPERATION_PERFORMANCE': 'positive'}</td>\n",
- " <td>{'GRAPHICS_GENERAL': 'positive'}</td>\n",
- " <td>{'HARD_DISC_DESIGN_FEATURES': 'positive'}</td>\n",
- " <td>{'LAPTOP_OPERATION_PERFORMANCE': 'positive'}</td>\n",
- " <td>{'LAPTOP_USABILITY': 'positive'}</td>\n",
- " <td>{'LAPTOP_USABILITY': 'positive'}</td>\n",
- " <td>{'LAPTOP_PORTABILITY': 'positive'}</td>\n",
- " <td>...</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>1</th>\n",
- " <td>the laptop was really good and it goes really ...</td>\n",
- " <td>{'LAPTOP_GENERAL': 'positive'}</td>\n",
- " <td>{'LAPTOP_OPERATION_PERFORMANCE': 'positive'}</td>\n",
- " <td>{'LAPTOP_GENERAL': 'positive'}</td>\n",
- " <td>{'LAPTOP_PRICE': 'positive'}</td>\n",
- " <td>{'LAPTOP_GENERAL': 'positive'}</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>...</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>2</th>\n",
- " <td>As a lifelong Windows user, I was extremely pl...</td>\n",
- " <td>{'LAPTOP_PORTABILITY': 'positive'}</td>\n",
- " <td>{'LAPTOP_QUALITY': 'positive'}</td>\n",
- " <td>{'LAPTOP_USABILITY': 'positive'}</td>\n",
- " <td>{'LAPTOP_DESIGN_FEATURES': 'positive'}</td>\n",
- " <td>{'LAPTOP_PORTABILITY': 'positive'}</td>\n",
- " <td>{'LAPTOP_MISCELLANEOUS': 'positive'}</td>\n",
- " <td>{'LAPTOP_MISCELLANEOUS': 'positive'}</td>\n",
- " <td>{'LAPTOP_QUALITY': 'positive'}</td>\n",
- " <td>{'OS_DESIGN_FEATURES': 'positive'}</td>\n",
- " <td>...</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3</th>\n",
- " <td>Oh my goodness-I am not a happy camper.My HP i...</td>\n",
- " <td>{'LAPTOP_GENERAL': 'negative'}</td>\n",
- " <td>{'LAPTOP_DESIGN_FEATURES': 'negative'}</td>\n",
- " <td>{'LAPTOP_PORTABILITY': 'negative'}</td>\n",
- " <td>{'BATTERY_QUALITY': 'negative'}</td>\n",
- " <td>{'BATTERY_OPERATION_PERFORMANCE': 'negative'}</td>\n",
- " <td>{'BATTERY_QUALITY': 'negative'}</td>\n",
- " <td>{'SUPPORT_QUALITY': 'negative'}</td>\n",
- " <td>{'SUPPORT_QUALITY': 'negative'}</td>\n",
- " <td>{'SUPPORT_QUALITY': 'negative'}</td>\n",
- " <td>...</td>\n",
- " <td>{'COMPANY_GENERAL': 'negative'}</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>4</th>\n",
- " <td>Since I purchased my Toshiba netbook, I have b...</td>\n",
- " <td>{'LAPTOP_GENERAL': 'positive'}</td>\n",
- " <td>{'LAPTOP_PORTABILITY': 'positive'}</td>\n",
- " <td>{'DISPLAY_USABILITY': 'neutral'}</td>\n",
- " <td>{'DISPLAY_DESIGN_FEATURES': 'neutral'}</td>\n",
- " <td>{'LAPTOP_GENERAL': 'positive'}</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>...</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " <td>None</td>\n",
- " </tr>\n",
- " </tbody>\n",
- "</table>\n",
- "<p>5 rows × 26 columns</p>\n",
- "</div>"
- ],
- "text/plain": [
- " text \\\n",
- "0 Being a PC user my whole life....This computer... \n",
- "1 the laptop was really good and it goes really ... \n",
- "2 As a lifelong Windows user, I was extremely pl... \n",
- "3 Oh my goodness-I am not a happy camper.My HP i... \n",
- "4 Since I purchased my Toshiba netbook, I have b... \n",
- "\n",
- " 0 \\\n",
- "0 {'LAPTOP_GENERAL': 'positive'} \n",
- "1 {'LAPTOP_GENERAL': 'positive'} \n",
- "2 {'LAPTOP_PORTABILITY': 'positive'} \n",
- "3 {'LAPTOP_GENERAL': 'negative'} \n",
- "4 {'LAPTOP_GENERAL': 'positive'} \n",
- "\n",
- " 1 \\\n",
- "0 {'BATTERY_OPERATION_PERFORMANCE': 'positive'} \n",
- "1 {'LAPTOP_OPERATION_PERFORMANCE': 'positive'} \n",
- "2 {'LAPTOP_QUALITY': 'positive'} \n",
- "3 {'LAPTOP_DESIGN_FEATURES': 'negative'} \n",
- "4 {'LAPTOP_PORTABILITY': 'positive'} \n",
- "\n",
- " 2 \\\n",
- "0 {'CPU_OPERATION_PERFORMANCE': 'positive'} \n",
- "1 {'LAPTOP_GENERAL': 'positive'} \n",
- "2 {'LAPTOP_USABILITY': 'positive'} \n",
- "3 {'LAPTOP_PORTABILITY': 'negative'} \n",
- "4 {'DISPLAY_USABILITY': 'neutral'} \n",
- "\n",
- " 3 \\\n",
- "0 {'GRAPHICS_GENERAL': 'positive'} \n",
- "1 {'LAPTOP_PRICE': 'positive'} \n",
- "2 {'LAPTOP_DESIGN_FEATURES': 'positive'} \n",
- "3 {'BATTERY_QUALITY': 'negative'} \n",
- "4 {'DISPLAY_DESIGN_FEATURES': 'neutral'} \n",
- "\n",
- " 4 \\\n",
- "0 {'HARD_DISC_DESIGN_FEATURES': 'positive'} \n",
- "1 {'LAPTOP_GENERAL': 'positive'} \n",
- "2 {'LAPTOP_PORTABILITY': 'positive'} \n",
- "3 {'BATTERY_OPERATION_PERFORMANCE': 'negative'} \n",
- "4 {'LAPTOP_GENERAL': 'positive'} \n",
- "\n",
- " 5 \\\n",
- "0 {'LAPTOP_OPERATION_PERFORMANCE': 'positive'} \n",
- "1 None \n",
- "2 {'LAPTOP_MISCELLANEOUS': 'positive'} \n",
- "3 {'BATTERY_QUALITY': 'negative'} \n",
- "4 None \n",
- "\n",
- " 6 7 \\\n",
- "0 {'LAPTOP_USABILITY': 'positive'} {'LAPTOP_USABILITY': 'positive'} \n",
- "1 None None \n",
- "2 {'LAPTOP_MISCELLANEOUS': 'positive'} {'LAPTOP_QUALITY': 'positive'} \n",
- "3 {'SUPPORT_QUALITY': 'negative'} {'SUPPORT_QUALITY': 'negative'} \n",
- "4 None None \n",
- "\n",
- " 8 ... 15 \\\n",
- "0 {'LAPTOP_PORTABILITY': 'positive'} ... None \n",
- "1 None ... None \n",
- "2 {'OS_DESIGN_FEATURES': 'positive'} ... None \n",
- "3 {'SUPPORT_QUALITY': 'negative'} ... {'COMPANY_GENERAL': 'negative'} \n",
- "4 None ... None \n",
- "\n",
- " 16 17 18 19 20 21 22 23 24 \n",
- "0 None None None None None None None None None \n",
- "1 None None None None None None None None None \n",
- "2 None None None None None None None None None \n",
- "3 None None None None None None None None None \n",
- "4 None None None None None None None None None \n",
- "\n",
- "[5 rows x 26 columns]"
- ]
- },
- "execution_count": 8,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "result = pd.concat([df1, df2], axis=1, sort=False)\n",
- "result.head()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 28,
- "metadata": {},
- "outputs": [],
- "source": [
- "result.to_csv(r'C:\\Users\\Kyuyeon Rhee\\myworks\\laptop2\\sentiment\\laptop_reviews.csv')"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.6.8"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 2
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement