zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
U
¬ý°dã@sddlmZddlmZddlZddlmZddlZddlm    Z    m
Z
m Z ddl Z ddl mZmZmZddlmZddlmZdd    lmZdd
lmZed d d dœdd„ƒZedddœdd„ƒZed&ddddœdd„ƒZeddœdd„ƒZeddœd d!„ƒZed'ddœd"d#„ƒZd$d%„ZdS)(é)Ú annotations)ÚcontextmanagerN)ÚPath)ÚIOÚAnyÚ    Generator)Ú
BaseBufferÚCompressionOptionsÚFilePath)ÚPYPY)ÚChainedAssignmentError)Ú
set_option)Ú
get_handlezFilePath | BaseBufferr    z Generator[IO[bytes], None, None])ÚpathÚ compressionÚreturnc    cs(t|d|dd}|jVW5QRXdS)a&
    Open a compressed file and return a file object.
 
    Parameters
    ----------
    path : str
        The path where the file is read from.
 
    compression : {'gzip', 'bz2', 'zip', 'xz', 'zstd', None}
        Name of the decompression to use
 
    Returns
    -------
    file object
    ÚrbF)rZis_textN)rÚhandle)rrr©rúOd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/_testing/contexts.pyÚdecompress_filesrÚstrzGenerator[(None, None, None)])Útzrc#sHddl‰ddœ‡fdd„ }tj d¡}||ƒz
dVW5||ƒXdS)a¼
    Context manager for temporarily setting a timezone.
 
    Parameters
    ----------
    tz : str
        A string representing a valid timezone.
 
    Examples
    --------
    >>> from datetime import datetime
    >>> from dateutil.tz import tzlocal
    >>> tzlocal().tzname(datetime(2021, 1, 1))  # doctest: +SKIP
    'IST'
 
    >>> with set_timezone('US/Eastern'):
    ...     tzlocal().tzname(datetime(2021, 1, 1))
    ...
    'EST'
    rNÚNone©rcsB|dkr,z tjd=Wq>tk
r(Yq>Xn|tjd<ˆ ¡dS)NÚTZ)ÚosÚenvironÚKeyErrorZtzset)r©ÚtimerrÚsetTZJs 
zset_timezone.<locals>.setTZr)r rrÚget)rr!Zorig_tzrrrÚ set_timezone2s
 
r#FÚboolrzGenerator[Any, None, None])Úreturn_filelikeÚkwargsrc    kstt ¡ƒ}|dkrd}tt ¡ƒ|}||}| ¡t|ƒ}|r\| dd¡t|f|Ž}z
|VW5t    |tƒsz| 
¡|  ¡rŠ|  ¡XdS)az
    Gets a temporary path and agrees to remove on close.
 
    This implementation does not use tempfile.mkstemp to avoid having a file handle.
    If the code using the returned path wants to delete the file itself, windows
    requires that no program has a file handle to it.
 
    Parameters
    ----------
    filename : str (optional)
        suffix of the created file.
    return_filelike : bool (default False)
        if True, returns a file-like which is *always* cleaned. Necessary for
        savefig and other functions which want to append extensions.
    **kwargs
        Additional keywords are passed to open().
 
    NÚÚmodezw+b) rÚtempfileÚ
gettempdirrÚuuidÚuuid4ÚtouchÚ
setdefaultÚopenÚ
isinstanceÚcloseÚis_fileÚunlink)Úfilenamer%r&ÚfolderrZ handle_or_strrrrÚ ensure_clean\s    
 
r6rc    cs2ttjƒ}z
dVW5tj ¡tj |¡XdS)zÚ
    Get a context manager to safely set environment variables
 
    All changes will be undone on close, hence environment variables set
    within this contextmanager will neither persist nor change global state.
    N)ÚdictrrÚclearÚupdate)Z saved_environrrrÚ!ensure_safe_environment_variables‰s
 
 
 
r:c    ksLddl}dddh}||kr"tdƒ‚|j|f|Žz
dVW5| |¡XdS)au
    Context manager to temporarily register a CSV dialect for parsing CSV.
 
    Parameters
    ----------
    name : str
        The name of the dialect.
    kwargs : mapping
        The parameters for the dialect.
 
    Raises
    ------
    ValueError : the name of the dialect conflicts with a builtin one.
 
    See Also
    --------
    csv : Python's CSV library.
    rNÚexcelz    excel-tabÚunixz Cannot override builtin dialect.)ÚcsvÚ
ValueErrorÚregister_dialectÚunregister_dialect)Únamer&r=Z_BUILTIN_DIALECTSrrrÚwith_csv_dialect™s
 
rBc    csXddlm}|dkr|j}|j}|j}td|ƒ||_z
dVW5||_td|ƒXdS)Nr)Ú expressionszcompute.use_numexpr)Zpandas.core.computationrCZ _MIN_ELEMENTSZ USE_NUMEXPRr )ZuseZ min_elementsÚexprZolduseZoldminrrrÚ use_numexpr»s 
 
rEcCs2trddlm}|ƒSddlm}|tddSdS)Nr)Ú nullcontext)Úassert_produces_warningzYA value is trying to be set on a copy of a DataFrame or Series through chained assignment)Úmatch)r Ú
contextlibrFZpandas._testingrGr )rFrGrrrÚraises_chained_assignment_errorÍs  ýrJ)NF)N) Ú
__future__rrIrrÚpathlibrr)Útypingrrrr+Zpandas._typingrr    r
Z pandas.compatr Z pandas.errorsr Zpandasr Zpandas.io.commonrrr#r6r:rBrErJrrrrÚ<module>s4       )ÿ,!