o
    $&]iF                     @  sf   d dl mZ d dlmZmZ d dlmZ d dlmZm	Z	m
Z
 er&d dlmZ G dd deed Zd	S )
    )annotations)TYPE_CHECKINGAny)StringNamespace)PandasLikeSeriesNamespacealign_and_extract_nativeis_dtype_pyarrow)PandasLikeSeriesc                   @  s   e Zd Zd7ddZd8ddZd9ddZd:ddZd;ddZd<ddZd=ddZ	d>dd Z
d?d"d#Zd@d%d&ZdAd)d*Zd@d+d,Zd7d-d.Zd7d/d0Zd7d1d2ZdBd4d5Zd6S )CPandasLikeSeriesStringNamespacereturnr	   c                 C     |  | jj S N)with_nativenativestrlenself r   ^/var/www/html/IGF-ODF-V3/venv/lib/python3.10/site-packages/narwhals/_pandas_like/series_str.py	len_chars      z)PandasLikeSeriesStringNamespace.len_charsvaluepatternr   literalboolnintc          	      C  sR   t | j|\}}t|ts| jj d}t|| jjj|||| d}| |S )Nz; backed `.str.replace` only supports str replacement values)patreplr   regex)	r   	compliant
isinstancer   _implementation	TypeErrorr   replacer   )	r   r   r   r   r   _value_nativemsgseriesr   r   r   r%      s   


z'PandasLikeSeriesStringNamespace.replacec                C  s   | j |||ddS )N)r   r   )r%   )r   r   r   r   r   r   r   replace_all"   s   z+PandasLikeSeriesStringNamespace.replace_all
characters
str | Nonec                 C     |  | jj|S r   )r   r   r   strip)r   r,   r   r   r   strip_chars'      z+PandasLikeSeriesStringNamespace.strip_charsprefixc                 C  r.   r   )r   r   r   
startswith)r   r2   r   r   r   starts_with*   r1   z+PandasLikeSeriesStringNamespace.starts_withsuffixc                 C  r.   r   )r   r   r   endswith)r   r5   r   r   r   	ends_with-   r1   z)PandasLikeSeriesStringNamespace.ends_withc                C  s   |  | jjj|| dS )N)r   r    )r   r   r   contains)r   r   r   r   r   r   r8   0   s   z(PandasLikeSeriesStringNamespace.containsoffsetlength
int | Nonec                 C  s(   |r|| nd }|  | jjj||dS )N)startstop)r   r   r   slice)r   r9   r:   r=   r   r   r   r>   3   s   z%PandasLikeSeriesStringNamespace.slicebyc                 C  s<   | j }| st| jjsd}t|| | jjj|dS )Na  This operation requires a pyarrow-backed series. Please refer to https://narwhals-dev.github.io/narwhals/api-reference/narwhals/#narwhals.maybe_convert_dtypes and ensure you are using dtype_backend='pyarrow'. Additionally, make sure you have pandas version 1.5+ and pyarrow installed. )r   )	implementationis_cudfr   r   dtyper$   r   r   split)r   r?   r@   r(   r   r   r   rC   7   s   z%PandasLikeSeriesStringNamespace.splitformatc                   sl    rt  fdddD r| | j ddS | | j dd}t|jdd  }r4|dkr4|jdS |S )	Nc                 3  s    | ]}| v V  qd S r   r   ).0xrD   r   r   	<genexpr>E   s    z>PandasLikeSeriesStringNamespace.to_datetime.<locals>.<genexpr>)z%zZT)utcF	time_zoneUTC)anyr   _to_datetimegetattrrB   dtconvert_time_zone)r   rD   resulttzr   rG   r   to_datetimeC   s   z+PandasLikeSeriesStringNamespace.to_datetimerJ   r   c                C  s4   | j  j| j||d}t| jjr|jddS |S )N)rD   rJ   pyarrow)dtype_backend)r@   to_native_namespacerT   r   r   rB   convert_dtypes)r   rD   rJ   rR   r   r   r   rN   L   s   

z,PandasLikeSeriesStringNamespace._to_datetimec                 C  s   | j |dj S )NrG   )rT   rP   date)r   rD   r   r   r   to_dateV   r   z'PandasLikeSeriesStringNamespace.to_datec                 C  r   r   )r   r   r   upperr   r   r   r   to_uppercaseY   r   z,PandasLikeSeriesStringNamespace.to_uppercasec                 C  r   r   )r   r   r   lowerr   r   r   r   to_lowercase\   r   z,PandasLikeSeriesStringNamespace.to_lowercasec                 C  r   r   )r   r   r   titler   r   r   r   to_titlecase_   r   z,PandasLikeSeriesStringNamespace.to_titlecasewidthc                 C  r.   r   )r   r   r   zfill)r   ra   r   r   r   rb   b   r1   z%PandasLikeSeriesStringNamespace.zfillN)r   r	   )
r   r	   r   r   r   r   r   r   r   r	   )r   r	   r   r   r   r   r   r	   )r,   r-   r   r	   )r2   r   r   r	   )r5   r   r   r	   )r   r   r   r   r   r	   )r9   r   r:   r;   r   r	   )r?   r   r   r	   )rD   r-   r   r	   )rD   r-   rJ   r   r   r   )ra   r   r   r	   )__name__
__module____qualname__r   r%   r+   r0   r4   r7   r8   r>   rC   rT   rN   rZ   r\   r^   r`   rb   r   r   r   r   r
      s"    










	




r
   r	   N)
__future__r   typingr   r   !narwhals._compliant.any_namespacer   narwhals._pandas_like.utilsr   r   r   narwhals._pandas_like.seriesr	   r
   r   r   r   r   <module>   s    
