# Import py_entitymatching package
import py_entitymatching as em
import os
import pandas as pd

"""
Explanation: Contents

Introduction
Removing Features

Introduction
This IPython notebook illustrates how to remove features from feature table.
First, we need to import py_entitymatching package and other libraries as follows:
End of explanation
"""


# Get the datasets directory
datasets_dir = em.get_install_path() + os.sep + 'datasets'

# Get the paths of the input tables
path_A = datasets_dir + os.sep + 'person_table_A.csv'
path_B = datasets_dir + os.sep + 'person_table_B.csv'

# Read the CSV files and set 'ID' as the key attribute
A = em.read_csv_metadata(path_A, key='ID')
B = em.read_csv_metadata(path_B, key='ID')

# Get features
feature_table = em.get_features_for_blocking(A, B)

"""
Explanation: Then, read the (sample) input tables for blocking purposes
End of explanation
"""


type(feature_table)

feature_table.head()

# Drop first row
feature_table = feature_table.drop(0)

feature_table.head()

#Remove all the features except involving name (Include only the features where the left attribute is name)
feature_table = feature_table[feature_table.left_attribute=='name']

feature_table

#Remove all the features except involving jaccard (Include only the features where the sim function is jaccard)
feature_table = feature_table[feature_table.simfunction=='jaccard']

feature_table

"""
Explanation: Removing Features from Feature Table
End of explanation
"""


