I’ve been trying to use google colabs tensorflow to compile a project of mine. It has no issue compiling with lower samples on my local machine (1000 and such) but takes too long when compiling all of the instances (42000).
def str_column_to_float(dataset, column):
for row in dataset:
value = row[column]
if isinstance(value, str): # Check if the value is a string
value = value.strip()
if not value.replace('.', '').isdigit(): # Check if the value is not numeric
continue
try:
row[column] = float(value)
except (ValueError, AttributeError):
pass # Skip conversion for non-numeric values
and this is the function call
filename = 'Train_data.csv'
dataset = load_csv(filename)
dataset = dataset[1:]
for i in range(0, len(dataset[0]) - 1):
str_column_to_float(dataset, i)
I haven’t found any issue and can’t see why this only happens in colabs and runs fine on vscode I’ve even tried to specify the columns that have the literal words in them but to no avail
`
def str_column_to_float(dataset, column):
for row in dataset:
row[column] = float(row[column].strip())
for i in range(0, len(dataset[0])-1):
if i not in [1, 2, 3, 42]: # Skip conversion for columns 1, 2, 3, and 42
str_column_to_float(dataset, i)
Obaid Sohail is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.