
     j}&                     l   d Z ddlmZ ddlZddlZddlZddlZej        	                    d           ddl
ZddlZddlmZmZmZmZmZmZmZmZmZmZmZmZmZmZ ddlmZ ddlmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1 d Z2d Z3d	 Z4d
 Z5d Z6d Z7d Z8e9dk    r e8             dS dS )a  
self-contained to write legacy storage pickle files

To use this script. Create an environment where you want
generate pickles, say its for 0.20.3, with your pandas clone
in ~/pandas

. activate pandas_0.20.3
cd ~/pandas/pandas

$ python -m tests.io.generate_legacy_storage_files     tests/io/data/legacy_pickle/0.20.3/ pickle

This script generates a storage file for the current arch, system,
and python version
  pandas version: 0.20.3
  output dir    : pandas/pandas/tests/io/data/legacy_pickle/0.20.3/
  storage format: pickle
created pickle file: 0.20.3_x86_64_darwin_3.5.2.pickle

The idea here is you are using the *current* version of the
generate_legacy_storage_files with an *older* version of pandas to
generate a pickle file. We will then check this file into a current
branch, and test using test_pickle.py. This will load the *older*
pickles and test versus the current data that is generated
(with main). These are then compared.

If we have cases where we changed the signature (e.g. we renamed
offset -> freq in Timestamp). Then we have to conditionally execute
in the generate_legacy_storage_files.py to make it
run under the older AND the newer version.

    )	timedeltaN)Categorical	DataFrameIndex
MultiIndexNaTPeriod
RangeIndexSeries	Timestampbdate_range
date_rangeinterval_rangeperiod_rangetimedelta_range)SparseArray)FY5253BusinessDayBusinessHourCustomBusinessDay
DateOffsetDayEasterHourLastWeekOfMonthMinute
MonthBeginMonthEndQuarterBegin
QuarterEndSemiMonthBeginSemiMonthEndWeekWeekOfMonth	YearBeginYearEndc                      t           j        } t          j        dt           j                  }| |dd<   | |dd <   t	          t          |d                    }d|_        |S )	N   dtype      blockkindbseries)npnanarangefloat64r   r   name)r3   arrr1   s      C:\Users\Terasoftware\OneDrive\Desktop\faahhh\fyndo\fyndo\venv\Lib\site-packages\pandas/tests/io/generate_legacy_storage_files.py_create_sp_seriesr9   Z   sa    
&C )Bbj
)
)
)CC"ICH[733344GGLN    c                     t           j        } t          j        dt           j                  }| |dd<   | |dd <   t	          dt          |                    }t          t          |d	          |
          }d|_        |S )Nr(   r)   r+   r,   r-   1/1/2011periodsr.   r/   index	btsseries)	r2   r3   r4   r5   r   lenr   r   r6   )r3   r7   
date_indexr1   s       r8   _create_sp_tsseriesrD   g   s~    
&C )Bbj
)
)
)CC"ICHZS:::J[7333:FFFGGLNr:   c                  6   t           j        } | | | dddddddg
ddd| | | ddddg
t          j        d                              t           j                  dddddd| | | | g
d	}t          d
d          }t          ||                              t                    S )Nr                     
   ABCDr<   r=   r?   )	r2   r3   r4   astypeint64r   r   applyr   )r3   datadatess      r8   _create_sp_framerW   u   s    
&C 3Q1aAq1AsCaAq1Yr]]!!"(++Aq!QS#s3	 D 
B///ET'''--k:::r:   c                    	 ddddt           j        gg dg dt          dd	          dd
t          d          ddgd	t          d          t	          dd          d} t          t          j        d                    t          dd	          t          ddd          t          t          j        dt           j                            t          t          j        dt           j	                            t          ddd          d}t          d          |d<   t          dd	          |d<   dt          j        t          t!          g dg dg           dd g!          i}t#          	d"                   t#          	d#                   t#          	d$                   t#          t          j        d                              t           j                  t          dd	          %          t#          t          j        d                              t           j                  t          j        t          t!          g d&g d'g           d(d)g!          %          t#          t          j        d                              t           j                  g d*%          t#          t)          g d+                    t#          t          dd	                    t#          t          ddd,-                    t#          t	          d.          gdz            d/
}t+          	          }t-          d0          |_        t+          |d1         |d1         d
z   d2          t+          |d3         |d3         d
z   d2          t+          	fd4d5D                       t+          t          j        d                              t           j                  t          j        d                              t           j                  d2t          j        t          t!          g d6g d7g           dd g!          %          t+          t          j        d8                              dd9                              t           j                  g d:;          t+          d"t)          dd<g          i          t+          t)          g d+          t          j        d9                              t           j                  d2          |t+          t          d=d,>          t          d?d@>          d2t3          d          %          t+          t          d=d,>          t          d?d@>          t          d?dA>          dBt3          d          %          dC
}t)          t-          dD                    t)          t          j        dE                    t)          t          j        dF                    dG}t          dH          t4          t          dHd,>          dI}i dJt7          d
K          dLt7          dMdNO          dPt9          t;          dQR          S          dTt=          dUdMdVW          dXt?          dYZ          d[tA          dQ\          d]tC          d^\          d_tE          d
          d`tG          d
          datI          d
          dbtK          d
          dctM          d
          ddtO          d
          detQ          d
          dftS          d
          dgtS          dhdid
j          dktU          d9dlm          tW          d
d9n          tY          dhdMdodpq          t[                      t]          d
          t_          d
          dr}|||| |ta                      tc                      dsd1te                      i|||dt
S )uzcreate the pickle datag        g      ?g       @g      @)r   rF   r   rF   r   )foo1foo2foo3foo4foo5z1/1/2009rJ   r=   rF   20100101foo)rN   rO   rP   rQ   E201301012012M)	timestampperiodrL   z
2013-01-01)freqr>   r)   z00:00:0030min)intdatere   floatuintr   ranger   intervalreg2)barro   bazrp   r_   r_   quxrq   )onetworr   rs   rr   rs   rr   rs   firstsecond)namesrN   rO   r`   r?   )rF   rF   rG   rG   rG   )rH   rI   rH   rI   rJ   rr   rs   )rN   rO   rP   rQ   rN   )r_   ro   rp   z
US/Eastern)r>   tz2000Q1)
rj   rh   mixedtsmidupcatdtdt_tzre   ABCDArj   )rN   rO   rh   c                 "    i | ]}||         S  r   ).0krU   s     r8   
<dictcomp>z&create_pickle_data.<locals>.<dictcomp>   s    EEE1AtAwEEEr:   rM   )ro   ro   rp   rp   rp   )rr   rs   rr   rs   threer(   rH   )rN   rO   rN   )columnsro   20130102)rw   20130603CETUTC)rN   rO   rP   )
rj   rh   ry   r{   r|   
cat_onecolcat_and_float	mixed_dupdt_mixed_tzsdt_mixed2_tzsabcdefgi  i'  )int8int16int32z
2011-01-01)normalnatrw   r   )yearsDateOffset_h_nsrK   i  )hournanosecondsr   	   )seconds)offsetr   Tz15:14)	normalizenendr   zMon Fri)weekmaskr!   )day_of_monthr"      r   r   r   r    r   r%   r&   r#   	Week_TuesrG   F)r   weekdayr$   rI   )weekr   )r   r   r+   last)r   r   startingMonth	variation)r   r   r   r   r   )rj   rz   )
seriesframer@   scalarsr{   	sp_seriessp_framer}   rd   offsets)3r2   r3   r   r   r	   r   r4   r   r5   uint64r   r
   r   r   from_tuplestuplezipr   rR   rS   r   r   listr   reshaperl   r   r   r   r   r   r   r!   r"   r   r   r   r    r   r%   r&   r#   r$   r   r   r   r   r   r9   rD   rW   )
r   r@   r{   r   mixed_dup_dfr   r}   rd   offrU   s
            @r8   create_pickle_datar      s    3S"&)__555
A...1i
++UC8 D &j11VFC=P=PQQG RYr]]##:r222|#rBBBry2:66677bi")44455$ZgrJJJ E  ^^E'N&q"555E* 	
&PPPPPP  H%

 

 


B S	""d3i  S	""IbMM  ***ZQS2T2T2T
 
 
 IaLL
++(cOOO___=>??u~  
 
 
 bill))"*55=V=V=VWWWk"7"7"78899Z
A66677
:q\JJJKK&**+a/00# F( T??L==Lvg7JKKLLve}6%=13DEEFFEEEE0DEEEFF)A,,%%bj11	!8K8KBH8U8UVV(???AAA  )
 
 

 
 
 IbMM!!!Q''..rz::OOO
 
 
  k5%.&A&A BCC" !6!6!677Yq\\((22 
 
 "!zl;;;ze444  ((
 
 
 #zl;;;ze444ze444 
 ((
 
 
I, ,E^ DOO,,RYt__--RYu--.. C L))666 Ijq))):1$??? 	{)A*>*>*>??? 	tqgFFF	
 	.	BBB 	.a888 	"555 	jmm 	HQKK 	Q 	jmm 	s1vv 	Yq\\ 	71:: 	Q  	T!ua888!" 	{1555#$ +Q:::1aqFKKK((Q))-  C4 022:M:O:OPP.001  r:   c            	      :   d                     t          t          j                  t          t	          j                              t          t	          j                                                              t          t	          j                              g          S )N_)	joinstrpandas__version__plmachinesystemlowerpython_versionr   r:   r8   platform_namer   !  sm    88"##
	!!##$$!##$$		
  r:   c                    t           j        }t          d           t          d|            t          d|             t          d           t                       d}t	          t
          j                            | |          d          5 }t          j	        t                      |t          j                   d d d            n# 1 swxY w Y   t          d|            d S )NzUThis script generates a storage file for the current arch, system, and python versionz  pandas version: z  output dir    : z  storage format: picklez.picklewbzcreated pickle file: )r   r   printr   openospathr   pickledumpr   DEFAULT_PROTOCOL)
output_dirversionpthfhs       r8   write_legacy_picklesr   ,  s1    G		   

(w
(
()))	
+z
+
+,,,	
$%%%__
%
%
%C	bgll:s++T	2	2 Gb&(("f.EFFFG G G G G G G G G G G G G G G 

'#
'
'(((((s   -CCCc                     t           j                            dd           dt          t           j                  cxk    rdk    sn t          j        d           t          t           j        d                   } t          t           j        d                   }t          j                            |           st          j	        |            |dk    rt          | 	           d S t          j        d
           d S )Nr    rH   rI   zhSpecify output directory and storage type: generate_legacy_storage_files.py <output_dir> <storage_type> rF   rG   r   )r   z&storage_type must be one of {'pickle'})sysr   insertrB   argvexitr   r   existsmkdirr   )r   storage_types     r8   write_legacy_filer   ?  s    HOOArCH 
 
 
 
 
 
 
 
<	
 	
 	

 SXa[!!Jsx{##L7>>*%% 
x ;
3333339:::::r:   __main__):__doc__datetimer   r   r   platformr   r   r   popnumpyr2   r   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   pandas.arraysr   pandas.tseries.offsetsr   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r9   rD   rW   r   r   r   r   __name__r   r:   r8   <module>r      s     D       				      



 Q                                      & % % % % %                                           0
 
 
  ; ; ;[ [ [|  ) ) )&; ; ;, z  r:   