@@ -9,14 +9,11 @@ Frequently Asked Questions (FAQ)
9
9
:suppress:
10
10
11
11
import numpy as np
12
+ import pandas as pd
13
+
12
14
np.random.seed(123456 )
13
15
np.set_printoptions(precision = 4 , suppress = True )
14
- import pandas as pd
15
16
pd.options.display.max_rows = 15
16
- import matplotlib
17
- # matplotlib.style.use('default')
18
- import matplotlib.pyplot as plt
19
- plt.close(' all' )
20
17
21
18
.. _df-memory-usage :
22
19
@@ -36,8 +33,7 @@ when calling :meth:`~DataFrame.info`:
36
33
dtypes = [' int64' , ' float64' , ' datetime64[ns]' , ' timedelta64[ns]' ,
37
34
' complex128' , ' object' , ' bool' ]
38
35
n = 5000
39
- data = dict ([(t, np.random.randint(100 , size = n).astype(t))
40
- for t in dtypes])
36
+ data = {t: np.random.randint(100 , size = n).astype(t) for t in dtypes}
41
37
df = pd.DataFrame(data)
42
38
df[' categorical' ] = df[' object' ].astype(' category' )
43
39
@@ -98,8 +94,8 @@ of the following code should be:
98
94
99
95
.. code-block :: python
100
96
101
- >> > if pd.Series([False , True , False ]): # noqa: E999
102
- ...
97
+ >> > if pd.Series([False , True , False ]):
98
+ ... pass
103
99
104
100
Should it be ``True `` because it's not zero-length, or ``False `` because there
105
101
are ``False `` values? It is unclear, so instead, pandas raises a ``ValueError ``:
@@ -329,8 +325,8 @@ constructors using something similar to the following:
329
325
330
326
.. ipython :: python
331
327
332
- x = np.array(list (range (10 )), ' >i4' ) # big endian
333
- newx = x.byteswap().newbyteorder() # force native byteorder
328
+ x = np.array(list (range (10 )), ' >i4' ) # big endian
329
+ newx = x.byteswap().newbyteorder() # force native byteorder
334
330
s = pd.Series(newx)
335
331
336
332
See `the NumPy documentation on byte order
0 commit comments