@@ -29,7 +29,7 @@ a default integer index:
2929 s = pd.Series([1 , 3 , 5 , np.nan, 6 , 8 ])
3030 s
3131
32- Creating a :class: `DataFrame ` by passing a NumPy array, with a datetime index
32+ Creating a :class: `DataFrame ` by passing a NumPy array, with a datetime index using :func: ` date_range `
3333and labeled columns:
3434
3535.. ipython :: python
@@ -93,14 +93,15 @@ Viewing data
9393
9494See the :ref: `Basics section <basics >`.
9595
96- Here is how to view the top and bottom rows of the frame:
96+ Use :meth: `DataFrame.head ` and :meth: `DataFrame.tail ` to view the top and bottom rows of the frame
97+ respectively:
9798
9899.. ipython :: python
99100
100101 df.head()
101102 df.tail(3 )
102103
103- Display the index, columns:
104+ Display the :attr: ` DataFrame. index` or :attr: ` DataFrame. columns` :
104105
105106.. ipython :: python
106107
@@ -116,7 +117,7 @@ while pandas DataFrames have one dtype per column**. When you call
116117of the dtypes in the DataFrame. This may end up being ``object ``, which requires
117118casting every value to a Python object.
118119
119- For ``df ``, our :class: `DataFrame ` of all floating-point values,
120+ For ``df ``, our :class: `DataFrame ` of all floating-point values, and
120121:meth: `DataFrame.to_numpy ` is fast and doesn't require copying data:
121122
122123.. ipython :: python
@@ -147,13 +148,13 @@ Transposing your data:
147148
148149 df.T
149150
150- Sorting by an axis:
151+ :meth: ` DataFrame.sort_index ` sorts by an axis:
151152
152153.. ipython :: python
153154
154155 df.sort_index(axis = 1 , ascending = False )
155156
156- Sorting by values:
157+ :meth: ` DataFrame.sort_values ` sorts by values:
157158
158159.. ipython :: python
159160
@@ -166,8 +167,8 @@ Selection
166167
167168 While standard Python / NumPy expressions for selecting and setting are
168169 intuitive and come in handy for interactive work, for production code, we
169- recommend the optimized pandas data access methods, `` .at ``, `` .iat ` `,
170- `` .loc `` and `` .iloc ` `.
170+ recommend the optimized pandas data access methods, :meth: ` DataFrame .at `, :meth: ` DataFrame .iat `,
171+ :meth: ` DataFrame .loc ` and :meth: ` DataFrame .iloc `.
171172
172173See the indexing documentation :ref: `Indexing and Selecting Data <indexing >` and :ref: `MultiIndex / Advanced Indexing <advanced >`.
173174
@@ -181,7 +182,7 @@ equivalent to ``df.A``:
181182
182183 df[" A" ]
183184
184- Selecting via ``[] ``, which slices the rows:
185+ Selecting via ``[] `` (`` __getitem__ ``) , which slices the rows:
185186
186187.. ipython :: python
187188
@@ -191,7 +192,7 @@ Selecting via ``[]``, which slices the rows:
191192 Selection by label
192193~~~~~~~~~~~~~~~~~~
193194
194- See more in :ref: `Selection by Label <indexing.label >`.
195+ See more in :ref: `Selection by Label <indexing.label >` using :meth: ` DataFrame.loc ` or :meth: ` DataFrame.at ` .
195196
196197For getting a cross section using a label:
197198
@@ -232,7 +233,7 @@ For getting fast access to a scalar (equivalent to the prior method):
232233 Selection by position
233234~~~~~~~~~~~~~~~~~~~~~
234235
235- See more in :ref: `Selection by Position <indexing.integer >`.
236+ See more in :ref: `Selection by Position <indexing.integer >` using :meth: ` DataFrame.iloc ` or :meth: ` DataFrame.at ` .
236237
237238Select via the position of the passed integers:
238239
@@ -361,19 +362,19 @@ returns a copy of the data:
361362 df1.loc[dates[0 ] : dates[1 ], " E" ] = 1
362363 df1
363364
364- To drop any rows that have missing data:
365+ :meth: ` DataFrame.dropna ` drops any rows that have missing data:
365366
366367.. ipython :: python
367368
368369 df1.dropna(how = " any" )
369370
370- Filling missing data:
371+ :meth: ` DataFrame.fillna ` fills missing data:
371372
372373.. ipython :: python
373374
374375 df1.fillna(value = 5 )
375376
376- To get the boolean mask where values are ``nan ``:
377+ :func: ` isna ` gets the boolean mask where values are ``nan ``:
377378
378379.. ipython :: python
379380
@@ -415,7 +416,7 @@ In addition, pandas automatically broadcasts along the specified dimension:
415416 Apply
416417~~~~~
417418
418- Applying functions to the data:
419+ :meth: ` DataFrame.apply ` applies a user defined function to the data:
419420
420421.. ipython :: python
421422
@@ -461,7 +462,7 @@ operations.
461462
462463See the :ref: `Merging section <merging >`.
463464
464- Concatenating pandas objects together with :func: `concat `:
465+ Concatenating pandas objects together along an axis with :func: `concat `:
465466
466467.. ipython :: python
467468
@@ -482,7 +483,7 @@ Concatenating pandas objects together with :func:`concat`:
482483Join
483484~~~~
484485
485- SQL style merges . See the :ref: `Database style joining <merging.join >` section.
486+ :func: ` merge ` enables SQL style join types along specific columns . See the :ref: `Database style joining <merging.join >` section.
486487
487488.. ipython :: python
488489
@@ -572,7 +573,7 @@ columns:
572573 stacked = df2.stack()
573574 stacked
574575
575- With a "stacked" DataFrame or Series (having a `` MultiIndex ` ` as the
576+ With a "stacked" DataFrame or Series (having a :class: ` MultiIndex ` as the
576577``index ``), the inverse operation of :meth: `~DataFrame.stack ` is
577578:meth: `~DataFrame.unstack `, which by default unstacks the **last level **:
578579
@@ -599,7 +600,7 @@ See the section on :ref:`Pivot Tables <reshaping.pivot>`.
599600 )
600601 df
601602
602- We can produce pivot tables from this data very easily:
603+ :func: ` pivot_table ` pivots a :class: ` DataFrame ` specifying the `` values ``, `` index `` and `` columns ``
603604
604605.. ipython :: python
605606
@@ -620,7 +621,7 @@ financial applications. See the :ref:`Time Series section <timeseries>`.
620621 ts = pd.Series(np.random.randint(0 , 500 , len (rng)), index = rng)
621622 ts.resample(" 5Min" ).sum()
622623
623- Time zone representation :
624+ :meth: ` Series.tz_localize ` localizes a time series to a time zone :
624625
625626.. ipython :: python
626627
@@ -630,7 +631,7 @@ Time zone representation:
630631 ts_utc = ts.tz_localize(" UTC" )
631632 ts_utc
632633
633- Converting to another time zone:
634+ :meth: ` Series.tz_convert ` converts a timezones aware time series to another time zone:
634635
635636.. ipython :: python
636637
@@ -722,7 +723,7 @@ We use the standard convention for referencing the matplotlib API:
722723
723724 plt.close(" all" )
724725
725- The :meth: ` ~ plt.close ` method is used to `close <https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.close.html >`__ a figure window:
726+ The `` plt.close ` ` method is used to `close <https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.close.html >`__ a figure window:
726727
727728.. ipython :: python
728729
@@ -732,7 +733,7 @@ The :meth:`~plt.close` method is used to `close <https://matplotlib.org/3.1.1/ap
732733 @savefig series_plot_basic.png
733734 ts.plot();
734735
735- If running under Jupyter Notebook, the plot will appear on :meth: `~ts .plot `. Otherwise use
736+ If running under Jupyter Notebook, the plot will appear on :meth: `~Series .plot `. Otherwise use
736737`matplotlib.pyplot.show <https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.show.html >`__ to show it or
737738`matplotlib.pyplot.savefig <https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.savefig.html >`__ to write it to a file.
738739
@@ -756,19 +757,19 @@ of the columns with labels:
756757 @savefig frame_plot_basic.png
757758 plt.legend(loc = ' best' );
758759
759- Getting data in/out
760- -------------------
760+ Importing and exporting data
761+ ----------------------------
761762
762763CSV
763764~~~
764765
765- :ref: `Writing to a csv file: <io.store_in_csv >`
766+ :ref: `Writing to a csv file: <io.store_in_csv >` using :meth: ` DataFrame.to_csv `
766767
767768.. ipython :: python
768769
769770 df.to_csv(" foo.csv" )
770771
771- :ref: `Reading from a csv file: <io.read_csv_table >`
772+ :ref: `Reading from a csv file: <io.read_csv_table >` using :func: ` read_csv `
772773
773774.. ipython :: python
774775
@@ -786,13 +787,13 @@ HDF5
786787
787788Reading and writing to :ref: `HDFStores <io.hdf5 >`.
788789
789- Writing to a HDF5 Store:
790+ Writing to a HDF5 Store using :meth: ` DataFrame.to_hdf ` :
790791
791792.. ipython :: python
792793
793794 df.to_hdf(" foo.h5" , " df" )
794795
795- Reading from a HDF5 Store:
796+ Reading from a HDF5 Store using :func: ` read_hdf ` :
796797
797798.. ipython :: python
798799
@@ -806,15 +807,15 @@ Reading from a HDF5 Store:
806807 Excel
807808~~~~~
808809
809- Reading and writing to :ref: `MS Excel <io.excel >`.
810+ Reading and writing to :ref: `Excel <io.excel >`.
810811
811- Writing to an excel file:
812+ Writing to an excel file using :meth: ` DataFrame.to_excel ` :
812813
813814.. ipython :: python
814815
815816 df.to_excel(" foo.xlsx" , sheet_name = " Sheet1" )
816817
817- Reading from an excel file:
818+ Reading from an excel file using :func: ` read_excel ` :
818819
819820.. ipython :: python
820821
@@ -828,16 +829,13 @@ Reading from an excel file:
828829 Gotchas
829830-------
830831
831- If you are attempting to perform an operation you might see an exception like:
832+ If you are attempting to perform a boolean operation on a :class: `Series ` or :class: `DataFrame `
833+ you might see an exception like:
832834
833- .. code-block :: python
834-
835- >> > if pd.Series([False , True , False ]):
836- ... print (" I was true" )
837- Traceback
838- ...
839- ValueError : The truth value of an array is ambiguous. Use a.empty, a.any() or a.all().
835+ .. ipython :: python
836+ :okexcept:
840837
841- See :ref: `Comparisons<basics.compare> ` for an explanation and what to do.
838+ if pd.Series([False , True , False ]):
839+ print (" I was true" )
842840
843- See :ref: `Gotchas<gotchas> ` as well .
841+ See :ref: `Comparisons<basics.compare> ` and :ref: ` Gotchas<gotchas> ` for an explanation and what to do .
0 commit comments