Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit a7b49ae

Browse files
Update connector.py
Changeed docstring and arguments from `df` to `table`
1 parent fa8d853 commit a7b49ae

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

labelpandas/connector.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
from tqdm.autonotebook import tqdm
66
import math
77

8-
def create_upload_dict(df:pandas.core.frame.DataFrame, lb_client:Client, base_client:baseClient, row_data_col:str,
8+
def create_upload_dict(table:pandas.core.frame.DataFrame, lb_client:Client, base_client:baseClient, row_data_col:str,
99
global_key_col:str="", external_id_col:str="", metadata_index:dict={}, local_files:bool=False,
1010
divider:str="///", verbose=False):
1111
""" Multithreads over a Pandas DataFrame, calling create_data_rows() on each row to return an upload dictionary
1212
Args:
13-
df : Required (pandas.core.frame.DataFrame) - Pandas DataFrame
13+
table : Required (pandas.core.frame.DataFrame) - Pandas DataFrame
1414
lb_client : Required (labelbox.client.Client) - Labelbox Client object
1515
base_client : Required (labelbase.client.Client) - Labelbase Client object
1616
row_data_col : Required (str) - Column containing asset URL or file path
@@ -29,7 +29,7 @@ def create_upload_dict(df:pandas.core.frame.DataFrame, lb_client:Client, base_cl
2929
- errors - List of dictionaries containing conversion error information; see connector.create_data_rows() for more information
3030
"""
3131
if verbose:
32-
print(f'Creating upload list - {len(df)} rows in Pandas DataFrame')
32+
print(f'Creating upload list - {len(table)} rows in Pandas DataFrame')
3333
global_key_col = global_key_col if global_key_col else row_data_col
3434
external_id_col = external_id_col if external_id_col else global_key_col
3535
metadata_schema_to_name_key = base_client.get_metadata_schema_to_name_key(lb_mdo=False, divider=divider, invert=False)
@@ -40,7 +40,7 @@ def create_upload_dict(df:pandas.core.frame.DataFrame, lb_client:Client, base_cl
4040
futures = []
4141
if verbose:
4242
print(f'Submitting data rows...')
43-
for index, row in df.iterrows():
43+
for index, row in table.iterrows():
4444
futures.append(exc.submit(
4545
create_data_rows, lb_client, base_client, row, metadata_name_key_to_schema, metadata_schema_to_name_key,
4646
row_data_col, global_key_col, external_id_col, metadata_index, local_files, divider
@@ -110,33 +110,33 @@ def create_data_rows(lb_client:Client, base_client:baseClient, row:pandas.core.s
110110
return_value["data_row"]["global_key"] = str(row[global_key_col])
111111
return return_value
112112

113-
def get_columns_function(df):
113+
def get_columns_function(table:pandas.core.frame.DataFrame):
114114
"""Grabs all column names from a Pandas DataFrame
115115
Args:
116116
df : Required (pandas.core.frame.DataFrame) - Pandas DataFrame
117117
Returns:
118118
List of strings corresponding to all column names
119119
"""
120-
return [col for col in df.columns]
120+
return [col for col in table.columns]
121121

122-
def get_unique_values_function(df, column_name:str):
122+
def get_unique_values_function(table:pandas.core.frame.DataFrame, column_name:str):
123123
"""Grabs all unique values from a column in a Pandas DataFrame
124124
Args:
125125
df : Required (pandas.core.frame.DataFrame) - Pandas DataFrame
126126
column_name : Required (str) - Column name
127127
Returns:
128128
List of strings corresponding to all unique values in a column
129129
"""
130-
return list(df[column_name].unique())
130+
return list(table[column_name].unique())
131131

132-
def add_column_function(df, column_name:str, default_value=""):
132+
def add_column_function(table:pandas.core.frame.DataFrame, column_name:str, default_value=""):
133133
""" Adds a column of empty values to an existing Pandas DataFrame
134134
Args:
135-
df : Required (pandas.core.frame.DataFrame) - Pandas DataFrame
135+
table : Required (pandas.core.frame.DataFrame) - Pandas DataFrame
136136
column_name : Required (str) - Column name
137137
default_value : Optional - Value to insert for every row in the newly created column
138138
Returns:
139-
Your Pandas DataFrame with a new column
139+
Your table with a new column given the column_name and default_value
140140
"""
141-
df[column_name] = default_value
142-
return df
141+
table[column_name] = default_value
142+
return table

0 commit comments

Comments
 (0)