o
    i                     @   sr   d dl mZ d dlmZ d dlmZ d dlmZ d dl	m
Z
mZ ddded	ed
ededejeef f
ddZdS )    )Any)	DataFrame)numpy)
IndexOrder)ArrayListfortran)orderdfwritabletargetr	   returnc                C   s   | j  D ]\}}|tkrd|d| d}t|dq| jdkr6| j  d tkr6| | jd  j|d}n| j||d}|j	t
krOd	| d
| j }t||S )zAConvert a DataFrame to a NumPy array for use with Jax or PyTorch.zcannot convert List column z to z (use Array dtype instead)N   r   )r   )r   r	   zcannot convert DataFrame to z/ (mixed type columns result in `object` dtype)
)Zschemaitemsr   	TypeErrorwidthZdtypesr   columnsZto_numpyZdtypeobject)r
   r   r   r	   nmtpmsgZarr r   J/home/app/Keep/.python/lib/python3.10/site-packages/polars/ml/utilities.pyframe_to_numpy	   s   

r   N)typingr   Zpolarsr   Zpolars._dependenciesr   npZpolars._typingr   Zpolars.datatypesr   r   boolstrZndarrayr   r   r   r   r   <module>   s"    