-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlexical.py
25 lines (18 loc) · 904 Bytes
/
lexical.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Jul 25 15:34:08 2019
@author: sanjanamendu
"""
import pandas as pd
# =============================================================================
# LIWC (External Software Required)
# =============================================================================
df = pd.read_csv("liwc_fbmsg (participant+direction).csv") \
.rename(columns={'Source (A)':'PID', 'Source (B)': 'Direction', 'Source (C)': 'Content'}) \
.drop(['Content','WC'],1)
lexical_feat = pd.merge(df.loc[df.Direction == 'Incoming'].drop('Direction',1),
df.loc[df.Direction == 'Outgoing'].drop('Direction',1),
'left', on='PID', suffixes=["_incoming","_outgoing"]).reset_index()
lexical_feat.columns = lexical_feat.columns.str.lower()
lexical_feat.to_csv("lexical_feat.csv", index=False)