Return a Numpy array from a Pandas dataframe. Iterating over a DataFrame has weird side effects, such as the first row being the column names. Converting to Numpy is more safe.
(obj: Any)
| 150 | |
| 151 | |
| 152 | def if_pandas_df_convert_to_numpy(obj: Any) -> Any: |
| 153 | """Return a Numpy array from a Pandas dataframe. |
| 154 | |
| 155 | Iterating over a DataFrame has weird side effects, such as the first |
| 156 | row being the column names. Converting to Numpy is more safe. |
| 157 | """ |
| 158 | if pd is not None and isinstance(obj, pd.DataFrame): |
| 159 | return obj.values |
| 160 | else: |
| 161 | return obj |
| 162 | |
| 163 | |
| 164 | def image_to_url( |
no outgoing calls