a
    d=ic	                     @   s   d Z ddlZdd ZdS )z@Utility methods for working with the Experiment Data Access API.    Nc                 C   s   t |  j}| jd| jv r&ddgndddgddd} t |  j}||krXtd|  } d	| j_d
d | jj	D | j_	| S )a  Gets a pivoted wide-form pandas dataframe.

    The wide-form DataFrame has all its tags included as columns of the
    DataFrame, which is more convenient to work. If the condition of having
    uniform sets of step values across all tags in all runs is not met,
    this will error.

    Args:
      dataframe: pandas dataframe to pivot.

    Returns:
      Pivoted wide-form pandas dataframe.
    Raises:
      ValueError if step values across all tags are not uniform.
    Z	wall_timevaluerunsteptagF)valuesindexcolumnsZdropnazpivoted DataFrame contains missing value(s). This is likely due to two timeseries having different sets of steps in your experiment. You can avoid this error by calling `get_scalars()` with `pivot=False` to disable the DataFrame pivoting.Nc                 S   s   g | ]}d qS )N ).0namer	   r	   t/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/tensorboard/data/experimental/utils.py
<listcomp>?       z#pivot_dataframe.<locals>.<listcomp>)
npZcount_nonzeroZisnullr   Zpivot_tabler   
ValueErrorZreset_indexr   names)Z	dataframeZnum_missing_0Znum_missing_1r	   r	   r   pivot_dataframe   s$    

r   )__doc__numpyr   r   r	   r	   r	   r   <module>   s   