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 lines161718191920214 unmodified lines262728303132293031323334373835363738394041424344454647484945505152535448495055565758596015 unmodified lines st.write(f"An error occurred: {e}") return ["Error occurred while tokenizing"] * len(questions)
# Check for token limit if inputs["input_ids"].shape[1] > 512: st.warning("Token limit exceeded for chunk") return ["Token limit exceeded for chunk"] * len(questions)4 unmodified lines outputs.logits.detach(), outputs.logits_aggregation.detach() ) st.write(f"Testing DataFrame iloc: {chunk.iloc[0, 8]}") # Debugging line
answers = [] for coordinates in predicted_answer_coordinates: if len(coordinates) == 1: row, col = coordinates[0] try: st.write(f"Trying to access row {coordinates[0][0]}, col {coordinates[0][1]}") # Debugging line answers.append(chunk.iloc[coordinates[0]].values) st.write(f"Trying to access row {row}, col {col}") # Debugging line value = 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 = coordinate try: value = chunk.iloc[row, col] if isinstance(value, pd.Series): cell_values.append(chunk.iloc[coordinate].values) 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(cell_values)) return answers
answers.append(", ".join(map(str, cell_values)))
return answers
app.py+16-10