18
18
class IntCastingNaNError (ValueError ):
19
19
"""
20
20
Exception raised when converting (``astype``) an array with NaN to an integer type.
21
+
22
+ Examples
23
+ --------
24
+ >>> pd.DataFrame(np.array([[1, np.nan], [2, 3]]), dtype="i8")
25
+ Traceback (most recent call last):
26
+ IntCastingNaNError: Cannot convert non-finite values (NA or inf) to integer
21
27
"""
22
28
23
29
@@ -27,6 +33,13 @@ class NullFrequencyError(ValueError):
27
33
28
34
Particularly ``DatetimeIndex.shift``, ``TimedeltaIndex.shift``,
29
35
``PeriodIndex.shift``.
36
+
37
+ Examples
38
+ --------
39
+ >>> df = pd.DatetimeIndex(["2011-01-01 10:00", "2011-01-01"], freq=None)
40
+ >>> df.shift(2)
41
+ Traceback (most recent call last):
42
+ NullFrequencyError: Cannot shift with no freq
30
43
"""
31
44
32
45
@@ -63,6 +76,17 @@ class ParserError(ValueError):
63
76
--------
64
77
read_csv : Read CSV (comma-separated) file into a DataFrame.
65
78
read_html : Read HTML table into a DataFrame.
79
+
80
+ Examples
81
+ --------
82
+ >>> data = '''a,b,c
83
+ ... cat,foo,bar
84
+ ... dog,foo,"baz'''
85
+ >>> from io import StringIO
86
+ >>> pd.read_csv(StringIO(data), skipfooter=1, engine='python')
87
+ Traceback (most recent call last):
88
+ ParserError: ',' expected after '"'. Error could possibly be due
89
+ to parsing errors in the skipped footer rows
66
90
"""
67
91
68
92
@@ -181,6 +205,18 @@ class MergeError(ValueError):
181
205
Exception raised when merging data.
182
206
183
207
Subclass of ``ValueError``.
208
+
209
+ Examples
210
+ --------
211
+ >>> left = pd.DataFrame({"a": ["a", "b", "b", "d"],
212
+ ... "b": ["cat", "dog", "weasel", "horse"]},
213
+ ... index=range(4))
214
+ >>> right = pd.DataFrame({"a": ["a", "b", "c", "d"],
215
+ ... "c": ["meow", "bark", "chirp", "nay"]},
216
+ ... index=range(4)).set_index("a")
217
+ >>> left.join(right, on="a", validate="one_to_one",)
218
+ Traceback (most recent call last):
219
+ MergeError: Merge keys are not unique in left dataset; not a one-to-one merge
184
220
"""
185
221
186
222
@@ -225,6 +261,17 @@ def __str__(self) -> str:
225
261
class NumbaUtilError (Exception ):
226
262
"""
227
263
Error raised for unsupported Numba engine routines.
264
+
265
+ Examples
266
+ --------
267
+ >>> df = pd.DataFrame({"key": ["a", "a", "b", "b"], "data": [1, 2, 3, 4]},
268
+ ... columns=["key", "data"])
269
+ >>> def incorrect_function(x):
270
+ ... return sum(x) * 2.7
271
+ >>> df.groupby("key").agg(incorrect_function, engine="numba")
272
+ Traceback (most recent call last):
273
+ NumbaUtilError: The first 2 arguments to incorrect_function
274
+ must be ['values', 'index']
228
275
"""
229
276
230
277
0 commit comments