Spaces:
Build error
Build error
Commit ·
515be2e
1
Parent(s): c1ca766
more iloc errors and (str)
Browse filesThe iloc operation seems to be returning a single value (in this case, a string) rather than a Series or DataFrame. This is why you're seeing the error 'str' object has no attribute 'values'.
The error iloc cannot enlarge its target object suggests that we're trying to access an index that might be out of bounds.
Based on these issues, I propose the following adjustments:
Replace .values with .item() for scalar values, which will safely convert single values to their respective native Python types.
Add some additional checks and logging to understand the shape and type of data you're working with.
15 unmodified lines161718192021224 unmodified lines2728293031323334353637383940414243444546474849505152535415 unmodified linesst.write(f"An error occurred: {e}")return ["Error occurred while tokenizing"] * len(questions)# Check for token limitif inputs["input_ids"].shape[1] > 512:st.warning("Token limit exceeded for chunk")return ["Token limit exceeded for chunk"] * len(questions)4 unmodified linesoutputs.logits.detach(),outputs.logits_aggregation.detach())st.write(f"Testing DataFrame iloc: {chunk.iloc[0, 8]}") # Debugging lineanswers = []for coordinates in predicted_answer_coordinates:if len(coordinates) == 1:try:st.write(f"Trying to access row {coordinates[0][0]}, col {coordinates[0][1]}") # Debugging lineanswers.append(chunk.iloc[coordinates[0]].values)except Exception as e:st.write(f"An error occurred: {e}")else:cell_values = []for coordinate in coordinates:try:cell_values.append(chunk.iloc[coordinate].values)except Exception as e:st.write(f"An error occurred: {e}")answers.append(", ".join(cell_values))return answers15 unmodified lines1617181920214 unmodified lines262728293031323334353637383940414243444546474849505152535455565758596015 unmodified linesst.write(f"An error occurred: {e}")return ["Error occurred while tokenizing"] * len(questions)if inputs["input_ids"].shape[1] > 512:st.warning("Token limit exceeded for chunk")return ["Token limit exceeded for chunk"] * len(questions)4 unmodified linesoutputs.logits.detach(),outputs.logits_aggregation.detach())answers = []for coordinates in predicted_answer_coordinates:if len(coordinates) == 1:row, col = coordinates[0]try:st.write(f"Trying to access row {row}, col {col}") # Debugging linevalue = chunk.iloc[row, col]if isinstance(value, pd.Series):answers.append(value.values)else:answers.append(value.item() if hasattr(value, 'item') else value)except Exception as e:st.write(f"An error occurred: {e}")else:cell_values = []for coordinate in coordinates:row, col = coordinatetry:value = chunk.iloc[row, col]if isinstance(value, pd.Series):cell_values.append(value.values)else:cell_values.append(value.item() if hasattr(value, 'item') else value)except Exception as e:st.write(f"An error occurred: {e}")answers.append(", ".join(map(str, cell_values)))return answers
app.py+16-10