KashyapiNagaHarshitha commited on
Commit
5d75f4a
·
verified ·
1 Parent(s): c3ab6f2

Update my_modules.py

Browse files
Files changed (1) hide show
  1. my_modules.py +14 -1
my_modules.py CHANGED
@@ -369,10 +369,23 @@ def verify_line_no(filename, lines_read):
369
  return None
370
 
371
 
372
- def rgb_tuple_from_str(rgb_str):
373
  rgb_str = rgb_str.replace("(","").replace(")","").replace(" ","")
374
  rgb = list(map(float,rgb_str.split(",")))
375
  return tuple(rgb)
 
 
 
 
 
 
 
 
 
 
 
 
 
376
 
377
  def color_dict_to_df(cd, column_name):
378
  df = pd.DataFrame.from_dict(cd, orient = 'index')
 
369
  return None
370
 
371
 
372
+ ''' def rgb_tuple_from_str(rgb_str):
373
  rgb_str = rgb_str.replace("(","").replace(")","").replace(" ","")
374
  rgb = list(map(float,rgb_str.split(",")))
375
  return tuple(rgb)
376
+ '''
377
+
378
+ def rgb_tuple_from_str(rgb_str):
379
+ # Remove unwanted characters and clean the string
380
+ rgb_str = rgb_str.replace("(", "").replace(")", "").replace(" ", "").replace("np.float64", "")
381
+ # Split the cleaned string and convert to float
382
+ try:
383
+ rgb = list(map(float, rgb_str.split(",")))
384
+ except ValueError as e:
385
+ print(f"Error converting string to float: {rgb_str}")
386
+ raise e
387
+ return tuple(rgb)
388
+
389
 
390
  def color_dict_to_df(cd, column_name):
391
  df = pd.DataFrame.from_dict(cd, orient = 'index')