96abhishekarora commited on
Commit
3ad4fe0
·
verified ·
1 Parent(s): d1c30b8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -25
app.py CHANGED
@@ -6,7 +6,7 @@ import linktransformer as lt
6
  def convert_df_to_csv(df):
7
  return df.to_csv().encode('utf-8')
8
 
9
- st.title('DataFrame Merger using LinkTransformer')
10
 
11
  # Function to load DataFrame
12
  def load_dataframe(upload):
@@ -39,31 +39,37 @@ if df2 is not None:
39
 
40
  # Model selection
41
  model_path = st.text_input("Model path (HuggingFace or local)", value="all-MiniLM-L6-v2")
 
42
 
43
- # Checkbox for columns to match on
44
- if not df1.empty and not df2.empty:
45
- columns_df1 = df1.columns.tolist()
46
- columns_df2 = df2.columns.tolist()
47
-
48
- selected_columns_df1 = st.multiselect("Select columns from DataFrame 1 to match on:", columns_df1, default=columns_df1[0])
49
- selected_columns_df2 = st.multiselect("Select columns from DataFrame 2 to match on:", columns_df2, default=columns_df2[0])
50
-
51
- # Perform merge
52
- if st.button("Merge DataFrames"):
53
- model=lt.LinkTransformer(model_path)
54
- df_lm_matched = lt.merge(df2, df1, merge_type='1:m', on=None, model=model, left_on=selected_columns_df1, right_on=selected_columns_df2)
55
- st.write("Merged DataFrame Preview:")
56
- st.dataframe(df_lm_matched.head())
57
 
58
- # Download button for merged DataFrame
59
- csv = convert_df_to_csv(df_lm_matched)
60
- st.download_button(
61
- label="Download merged DataFrame as CSV",
62
- data=csv,
63
- file_name='merged_dataframe.csv',
64
- mime='text/csv',
65
- )
 
 
 
 
66
  else:
67
  st.write("Please upload or enter paths for both DataFrames.")
68
-
69
-
 
 
 
6
  def convert_df_to_csv(df):
7
  return df.to_csv().encode('utf-8')
8
 
9
+ st.title('Merge Dataframes using LinkTransformer')
10
 
11
  # Function to load DataFrame
12
  def load_dataframe(upload):
 
39
 
40
  # Model selection
41
  model_path = st.text_input("Model path (HuggingFace or local)", value="all-MiniLM-L6-v2")
42
+ ##More on model selection available on https://linktransformer.github.io/
43
 
44
+ if not df1==None and not df2==None:
45
+ # Checkbox for columns to match on
46
+ if not df1.empty and not df2.empty:
47
+ columns_df1 = df1.columns.tolist()
48
+ columns_df2 = df2.columns.tolist()
49
+ selected_columns_df1 = st.multiselect("Select columns from DataFrame 1 to match on:", columns_df1, default=columns_df1[0])
50
+ selected_columns_df2 = st.multiselect("Select columns from DataFrame 2 to match on:", columns_df2, default=columns_df2[0])
51
+ # Perform merge
52
+ if st.button("Merge DataFrames"):
53
+ model=lt.LinkTransformer(model_path)
54
+ df_lm_matched = lt.merge(df2, df1, merge_type='1:m', on=None, model=model, left_on=selected_columns_df1, right_on=selected_columns_df2)
55
+ st.write("Merged DataFrame Preview:")
56
+ st.dataframe(df_lm_matched.head())
 
57
 
58
+ # Download button for merged DataFrame
59
+ csv = convert_df_to_csv(df_lm_matched)
60
+ st.download_button(
61
+ label="Download merged DataFrame as CSV",
62
+ data=csv,
63
+ file_name='merged_dataframe.csv',
64
+ mime='text/csv',
65
+ )
66
+ else:
67
+ st.write("It appears that your dataframes are empty. Please upload valid dataframes.")
68
+
69
+
70
  else:
71
  st.write("Please upload or enter paths for both DataFrames.")
72
+
73
+ ##Add website and citation
74
+ st.write("For more information, please visit the [LinkTransformer website](https://linktransformer.github.io/).")
75
+ st.write("If you use LinkTransformer in your research, please cite the following paper: [LinkTransformer: A Unified Package for Record Linkage with Transformer Language Models](https://arxiv.org/abs/2309.00789)")