zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
U
­ý°dD'ã@s8dZddlmZddlZddlZddlZddlZddlZ    ddl
Z
ddl
m Z m Z m Z mZmZmZmZmZmZmZmZmZmZmZddlmZddlmZmZmZmZm 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/dd„Z0d    d
„Z1d d „Z2d d„Z3dd„Z4dd„Z5dd„Z6dd„Z7e8dkr4e7ƒdS)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ÚYearEndcCsHtj}tjdtjd}||dd…<||dd…<tt|ddƒ}d|_|S)    Né©Zdtypeéé éÿÿÿÿÚblock©ÚkindÚbseries)ÚnpÚnanÚarangeÚfloat64r
rÚname)r0Úarrr.©r5údd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/tests/io/generate_legacy_storage_files.pyÚ_create_sp_seriesVs  r7cCs\tj}tjdtjd}||dd…<||dd…<tdt|ƒd}tt|dd    |d
}d |_|S) Nr&r'r(r)r*ú1/1/2011©Úperiodsr+r,©ÚindexZ    btsseries)    r/r0r1r2r Úlenr
rr3)r0r4Z
date_indexr.r5r5r6Ú_create_sp_tsseriescs  r>c Cs|tj}|||dddddddg
ddd|||ddddg
t d¡ tj¡dddddd||||g
d    œ}td
dd }t||d  t¡S) Nrééééééé
©ÚAÚBÚCÚDr8r9r;)    r/r0r1ÚastypeÚint64r rÚapplyr)r0ÚdataÚdatesr5r5r6Ú_create_sp_frameqsü rPc    s‚ddddtjgdddddgddd    d
d gtd d dddtdƒddgdœ‰tdƒtddƒdœ}tt d¡ƒtdddtddddttjdtjdƒttjdtj    dƒt
dddddœ}t dƒ|d<t ddd|d<dt jttd d d!d!ddd"d"gd#d$d#d$d#d$d#d$ggŽƒd%d&gd'i}tˆd(ƒtˆd)ƒtˆd*ƒtt d¡ tj¡tdddd+tt d ¡ tj¡t jttddd,d,d,gd-d.d-d.d ggŽƒd#d$gd'd+tt d ¡ tj¡d(d)d/d0d(gd+ttdd d!gƒƒttdd dƒttdd d1d2ƒttd3ƒgd ƒd4œ
}tˆƒ}td5ƒ|_t|d6|d6dd7œƒt|d8|d8dd7œƒt‡fd9d:„d;Dƒƒtt d ¡ tj¡t d ¡ tj¡d7œt jttd d d!d!d!gd#d$d#d$d<ggŽƒd%d&gd'd+tt d=¡ d d-¡ tj¡d(d)d(gd>td(tdd gƒiƒttdd d!gƒt d-¡ tj¡d7œƒ|ttd?d1d@tdAdBd@d7œtd ƒd+ttd?d1d@tdAdBd@tdAdCd@dDœtd ƒd+dEœ
}ttdFƒƒtt dG¡ƒtt dH¡ƒdIœ}tdJƒttdJd1d@dKœ}tddLtdMdNdOttdPdQdRtdSdMdTdUtdVdWt dPdXt!dYdXt"dƒt#dƒt$dƒt%dƒt&dƒt'dƒt(dƒt)dƒt)d,dZdd[t*d-d.d\t+dd-d]t,d,dMd^d_d`t-ƒt.dƒt/dƒdaœ}|||||t0ƒt1ƒdbœd6t2ƒi|||dcœ
S)dzcreate the pickle dataggð?g@g@rr?Zfoo1Zfoo2Zfoo3Zfoo4Zfoo5z1/1/2009rCr9Z20100101Zfoo)rGrHrIrJÚEZ20130101Z2012ÚM)Ú    timestampÚperiodrEz
2013-01-01)Úfreqr:r'z00:00:00Z30T)ÚintÚdaterTÚfloatZuintrÚrangeÚintervalZreg2ÚbarZbazZquxZoneZtwoÚfirstÚsecond)ÚnamesrGrHrQr;r@rArBrIrJz
US/Eastern)r:ÚtzZ2000Q1)
rXrVÚmixedÚtsÚmiÚdupÚcatÚdtZdt_tzrTZABCDArX)rGrHrVcsi|]}|ˆ|“qSr5r5)Ú.0Úk©rNr5r6Ú
<dictcomp>¿szcreate_data.<locals>.<dictcomp>rFZthreer&)ÚcolumnsZ20130102)r_Z20130603ZCETÚUTC)rGrHrI)
rXrVr`rbrcZ
cat_onecolZ cat_and_floatZ    mixed_dupZ dt_mixed_tzsZ dt_mixed2_tzsZabcdefgièi')Zint8Úint16Úint32z
2011-01-01)ÚnormalZnatr_)ZyearsrDiÀ)ÚhourÚ nanosecondsé    )Úseconds)ÚoffsetTz15:14)Ú    normalizeÚnÚendzMon Fri)Zweekmask)Z day_of_monthéF)rtÚweekday)Úweekrx)rurxr(Úlast)rurxZ startingMonthZ    variation)rZDateOffset_h_nsrrrr r!rrrrrr$r%r"Z    Week_Tuesr#rrrrr)rXra)
ÚseriesÚframer<ÚscalarsrbZ    sp_seriesZsp_framerdrSÚoffsets)3r/r0r r rrr1rr2Zuint64rr    rrÚ from_tuplesÚtupleÚzipr
rKrLrrÚlistrjZreshaperYrrrrrrr r!rrrrrr$r%r"r#rrrrrr7r>rP)    r}r<rbr{Z mixed_dup_dfr|rdrSÚoffr5rhr6Ú create_datas
 
û 
  ú     þÿÿ÷ÿ
 
 
 
ÿ"ÿþ"ï
$  þÿÿ÷þÿ þÿ
 
þû
 
 
ýúÜ/
  ý
ý
 
 
ê ör„cCs
tƒ}|S)N)r„rhr5r5r6Úcreate_pickle_datasr…cCs4d ttjƒtt ¡ƒtt ¡ ¡ƒtt ¡ƒg¡S)NÚ_)    ÚjoinÚstrÚpandasÚ __version__ÚplÚmachineÚsystemÚlowerÚpython_versionr5r5r5r6Ú platform_name#s
 
üÿrc    Cs‚tj}tdƒtd|›ƒtd|›ƒtdƒtƒ›d}ttj ||¡dƒ}t     t
ƒ|tj ¡W5QRXtd|›ƒdS)NzUThis script generates a storage file for the current arch, system, and python versionz  pandas version: z  output dir    : z  storage format: picklez.pickleÚwbzcreated pickle file: ) r‰rŠÚprintrÚopenÚosÚpathr‡ÚpickleÚdumpr…ÚDEFAULT_PROTOCOL)Ú
output_dirÚversionÚpthÚfhr5r5r6Úwrite_legacy_pickles.sÿ rcCsrtj dd¡dttjƒkr(dks4nt d¡ttjdƒ}ttjdƒ}|dkrdt|d    n
t d
¡dS) NrÚ.rArBzhSpecify output directory and storage type: generate_legacy_storage_files.py <output_dir> <storage_type> r?r@r–)r™z&storage_type must be one of {'pickle'})Úsysr•Úinsertr=ÚargvÚexitrˆr)r™Z storage_typer5r5r6Úwrite_legacy_fileAsÿ r£Ú__main__)9Ú__doc__Údatetimerr”r–Úplatformr‹rŸÚnumpyr/r‰rrrrrrr    r
r r r rrrZ pandas.arraysrZpandas.tseries.offsetsrrrrrrrrrrrrrrr r!r"r#r$r%r7r>rPr„r…rrr£Ú__name__r5r5r5r6Ú<module>s*" @ X