Skip to content

Commit 7e7cb93

Browse files
committed
Merging
2 parents f24f7b9 + e79487d commit 7e7cb93

File tree

131 files changed

+5266
-3585
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+5266
-3585
lines changed

asv_bench/benchmarks/arithmetic.py

+25
Original file line numberDiff line numberDiff line change
@@ -469,4 +469,29 @@ def time_apply_index(self, offset):
469469
offset.apply_index(self.rng)
470470

471471

472+
class BinaryOpsMultiIndex:
473+
params = ["sub", "add", "mul", "div"]
474+
param_names = ["func"]
475+
476+
def setup(self, func):
477+
date_range = pd.date_range("20200101 00:00", "20200102 0:00", freq="S")
478+
level_0_names = [str(i) for i in range(30)]
479+
480+
index = pd.MultiIndex.from_product([level_0_names, date_range])
481+
column_names = ["col_1", "col_2"]
482+
483+
self.df = pd.DataFrame(
484+
np.random.rand(len(index), 2), index=index, columns=column_names
485+
)
486+
487+
self.arg_df = pd.DataFrame(
488+
np.random.randint(1, 10, (len(level_0_names), 2)),
489+
index=level_0_names,
490+
columns=column_names,
491+
)
492+
493+
def time_binary_op_multiindex(self, func):
494+
getattr(self.df, func)(self.arg_df, level=0)
495+
496+
472497
from .pandas_vb_common import setup # noqa: F401 isort:skip

asv_bench/benchmarks/indexing.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ def time_boolean_rows_boolean(self):
158158
class DataFrameNumericIndexing:
159159
def setup(self):
160160
self.idx_dupe = np.array(range(30)) * 99
161-
self.df = DataFrame(np.random.randn(10000, 5))
161+
self.df = DataFrame(np.random.randn(100000, 5))
162162
self.df_dup = concat([self.df, 2 * self.df, 3 * self.df])
163-
self.bool_indexer = [True] * 5000 + [False] * 5000
163+
self.bool_indexer = [True] * 50000 + [False] * 50000
164164

165165
def time_iloc_dups(self):
166166
self.df_dup.iloc[self.idx_dupe]

doc/source/development/contributing.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -1275,8 +1275,8 @@ Performance matters and it is worth considering whether your code has introduced
12751275
performance regressions. pandas is in the process of migrating to
12761276
`asv benchmarks <https://github.com/spacetelescope/asv>`__
12771277
to enable easy monitoring of the performance of critical pandas operations.
1278-
These benchmarks are all found in the ``pandas/asv_bench`` directory. asv
1279-
supports both python2 and python3.
1278+
These benchmarks are all found in the ``pandas/asv_bench`` directory, and the
1279+
test results can be found `here <https://pandas.pydata.org/speed/pandas/#/>`__.
12801280

12811281
To use all features of asv, you will need either ``conda`` or
12821282
``virtualenv``. For more details please check the `asv installation

doc/source/ecosystem.rst

+17
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,23 @@ A good implementation for Python users is `has2k1/plotnine <https://github.com/h
153153
Spun off from the main pandas library, the `qtpandas <https://github.com/draperjames/qtpandas>`__
154154
library enables DataFrame visualization and manipulation in PyQt4 and PySide applications.
155155

156+
`D-Tale <https://github.com/man-group/dtale>`__
157+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
158+
159+
D-Tale is a lightweight web client for visualizing pandas data structures. It
160+
provides a rich spreadsheet-style grid which acts as a wrapper for a lot of
161+
pandas functionality (query, sort, describe, corr...) so users can quickly
162+
manipulate their data. There is also an interactive chart-builder using Plotly
163+
Dash allowing users to build nice portable visualizations. D-Tale can be
164+
invoked with the following command
165+
166+
.. code:: python
167+
168+
import dtale; dtale.show(df)
169+
170+
D-Tale integrates seamlessly with jupyter notebooks, python terminals, kaggle
171+
& Google Colab. Here are some demos of the `grid <http://alphatechadmin.pythonanywhere.com/>`__
172+
and `chart-builder <http://alphatechadmin.pythonanywhere.com/charts/4?chart_type=surface&query=&x=date&z=Col0&agg=raw&cpg=false&y=%5B%22security_id%22%5D>`__.
156173

157174
.. _ecosystem.ide:
158175

doc/source/reference/frame.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,14 @@ Reshaping, sorting, transposing
240240
DataFrame.T
241241
DataFrame.transpose
242242

243-
Combining / joining / merging
244-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
243+
Combining / comparing / joining / merging
244+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
245245
.. autosummary::
246246
:toctree: api/
247247

248248
DataFrame.append
249249
DataFrame.assign
250+
DataFrame.compare
250251
DataFrame.join
251252
DataFrame.merge
252253
DataFrame.update

doc/source/reference/offset_frequency.rst

+38-34
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ Properties
5959
BusinessDay.normalize
6060
BusinessDay.rule_code
6161
BusinessDay.n
62+
BusinessDay.weekmask
63+
BusinessDay.holidays
64+
BusinessDay.calendar
6265

6366
Methods
6467
~~~~~~~
@@ -95,6 +98,9 @@ Properties
9598
BusinessHour.n
9699
BusinessHour.start
97100
BusinessHour.end
101+
BusinessHour.weekmask
102+
BusinessHour.holidays
103+
BusinessHour.calendar
98104

99105
Methods
100106
~~~~~~~
@@ -128,12 +134,16 @@ Properties
128134
CustomBusinessDay.normalize
129135
CustomBusinessDay.rule_code
130136
CustomBusinessDay.n
137+
CustomBusinessDay.weekmask
138+
CustomBusinessDay.calendar
139+
CustomBusinessDay.holidays
131140

132141
Methods
133142
~~~~~~~
134143
.. autosummary::
135144
:toctree: api/
136145

146+
CustomBusinessDay.apply_index
137147
CustomBusinessDay.apply
138148
CustomBusinessDay.copy
139149
CustomBusinessDay.isAnchored
@@ -161,6 +171,9 @@ Properties
161171
CustomBusinessHour.normalize
162172
CustomBusinessHour.rule_code
163173
CustomBusinessHour.n
174+
CustomBusinessHour.weekmask
175+
CustomBusinessHour.calendar
176+
CustomBusinessHour.holidays
164177
CustomBusinessHour.start
165178
CustomBusinessHour.end
166179

@@ -333,6 +346,9 @@ Properties
333346
CustomBusinessMonthEnd.normalize
334347
CustomBusinessMonthEnd.rule_code
335348
CustomBusinessMonthEnd.n
349+
CustomBusinessMonthEnd.weekmask
350+
CustomBusinessMonthEnd.calendar
351+
CustomBusinessMonthEnd.holidays
336352

337353
Methods
338354
~~~~~~~
@@ -367,6 +383,9 @@ Properties
367383
CustomBusinessMonthBegin.normalize
368384
CustomBusinessMonthBegin.rule_code
369385
CustomBusinessMonthBegin.n
386+
CustomBusinessMonthBegin.weekmask
387+
CustomBusinessMonthBegin.calendar
388+
CustomBusinessMonthBegin.holidays
370389

371390
Methods
372391
~~~~~~~
@@ -381,40 +400,6 @@ Methods
381400
CustomBusinessMonthBegin.is_on_offset
382401
CustomBusinessMonthBegin.__call__
383402

384-
SemiMonthOffset
385-
---------------
386-
.. autosummary::
387-
:toctree: api/
388-
389-
SemiMonthOffset
390-
391-
Properties
392-
~~~~~~~~~~
393-
.. autosummary::
394-
:toctree: api/
395-
396-
SemiMonthOffset.freqstr
397-
SemiMonthOffset.kwds
398-
SemiMonthOffset.name
399-
SemiMonthOffset.nanos
400-
SemiMonthOffset.normalize
401-
SemiMonthOffset.rule_code
402-
SemiMonthOffset.n
403-
404-
Methods
405-
~~~~~~~
406-
.. autosummary::
407-
:toctree: api/
408-
409-
SemiMonthOffset.apply
410-
SemiMonthOffset.apply_index
411-
SemiMonthOffset.copy
412-
SemiMonthOffset.isAnchored
413-
SemiMonthOffset.onOffset
414-
SemiMonthOffset.is_anchored
415-
SemiMonthOffset.is_on_offset
416-
SemiMonthOffset.__call__
417-
418403
SemiMonthEnd
419404
------------
420405
.. autosummary::
@@ -434,6 +419,7 @@ Properties
434419
SemiMonthEnd.normalize
435420
SemiMonthEnd.rule_code
436421
SemiMonthEnd.n
422+
SemiMonthEnd.day_of_month
437423

438424
Methods
439425
~~~~~~~
@@ -468,6 +454,7 @@ Properties
468454
SemiMonthBegin.normalize
469455
SemiMonthBegin.rule_code
470456
SemiMonthBegin.n
457+
SemiMonthBegin.day_of_month
471458

472459
Methods
473460
~~~~~~~
@@ -502,6 +489,7 @@ Properties
502489
Week.normalize
503490
Week.rule_code
504491
Week.n
492+
Week.weekday
505493

506494
Methods
507495
~~~~~~~
@@ -536,6 +524,7 @@ Properties
536524
WeekOfMonth.normalize
537525
WeekOfMonth.rule_code
538526
WeekOfMonth.n
527+
WeekOfMonth.week
539528

540529
Methods
541530
~~~~~~~
@@ -571,6 +560,7 @@ Properties
571560
LastWeekOfMonth.rule_code
572561
LastWeekOfMonth.n
573562
LastWeekOfMonth.weekday
563+
LastWeekOfMonth.week
574564

575565
Methods
576566
~~~~~~~
@@ -922,6 +912,7 @@ Properties
922912
FY5253Quarter.normalize
923913
FY5253Quarter.rule_code
924914
FY5253Quarter.n
915+
FY5253Quarter.qtr_with_extra_week
925916
FY5253Quarter.startingMonth
926917
FY5253Quarter.variation
927918
FY5253Quarter.weekday
@@ -1268,6 +1259,9 @@ Properties
12681259
BDay.offset
12691260
BDay.rule_code
12701261
BDay.n
1262+
BDay.weekmask
1263+
BDay.holidays
1264+
BDay.calendar
12711265

12721266
Methods
12731267
~~~~~~~
@@ -1383,6 +1377,9 @@ Properties
13831377
CBMonthEnd.offset
13841378
CBMonthEnd.rule_code
13851379
CBMonthEnd.n
1380+
CBMonthEnd.weekmask
1381+
CBMonthEnd.holidays
1382+
CBMonthEnd.calendar
13861383

13871384
Methods
13881385
~~~~~~~
@@ -1424,6 +1421,9 @@ Properties
14241421
CBMonthBegin.offset
14251422
CBMonthBegin.rule_code
14261423
CBMonthBegin.n
1424+
CBMonthBegin.weekmask
1425+
CBMonthBegin.holidays
1426+
CBMonthBegin.calendar
14271427

14281428
Methods
14291429
~~~~~~~
@@ -1462,6 +1462,9 @@ Properties
14621462
CDay.offset
14631463
CDay.rule_code
14641464
CDay.n
1465+
CDay.weekmask
1466+
CDay.calendar
1467+
CDay.holidays
14651468

14661469
Methods
14671470
~~~~~~~
@@ -1479,6 +1482,7 @@ Methods
14791482
CDay.rollforward
14801483
CDay.__call__
14811484

1485+
14821486
.. _api.frequencies:
14831487

14841488
===========

doc/source/reference/series.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,13 @@ Reshaping, sorting
240240
Series.squeeze
241241
Series.view
242242

243-
Combining / joining / merging
244-
-----------------------------
243+
Combining / comparing / joining / merging
244+
-----------------------------------------
245245
.. autosummary::
246246
:toctree: api/
247247

248248
Series.append
249+
Series.compare
249250
Series.replace
250251
Series.update
251252

doc/source/user_guide/gotchas.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ Byte-ordering issues
321321
--------------------
322322
Occasionally you may have to deal with data that were created on a machine with
323323
a different byte order than the one on which you are running Python. A common
324-
symptom of this issue is an error like:::
324+
symptom of this issue is an error like::
325325

326326
Traceback
327327
...

doc/source/user_guide/indexing.rst

+20-10
Original file line numberDiff line numberDiff line change
@@ -1866,29 +1866,39 @@ A chained assignment can also crop up in setting in a mixed dtype frame.
18661866

18671867
These setting rules apply to all of ``.loc/.iloc``.
18681868

1869-
This is the correct access method:
1869+
The following is the recommended access method using ``.loc`` for multiple items (using ``mask``) and a single item using a fixed index:
18701870

18711871
.. ipython:: python
18721872
1873-
dfc = pd.DataFrame({'A': ['aaa', 'bbb', 'ccc'], 'B': [1, 2, 3]})
1874-
dfc.loc[0, 'A'] = 11
1875-
dfc
1873+
dfc = pd.DataFrame({'a': ['one', 'one', 'two',
1874+
'three', 'two', 'one', 'six'],
1875+
'c': np.arange(7)})
1876+
dfd = dfc.copy()
1877+
# Setting multiple items using a mask
1878+
mask = dfd['a'].str.startswith('o')
1879+
dfd.loc[mask, 'c'] = 42
1880+
dfd
1881+
1882+
# Setting a single item
1883+
dfd = dfc.copy()
1884+
dfd.loc[2, 'a'] = 11
1885+
dfd
18761886
1877-
This *can* work at times, but it is not guaranteed to, and therefore should be avoided:
1887+
The following *can* work at times, but it is not guaranteed to, and therefore should be avoided:
18781888

18791889
.. ipython:: python
18801890
:okwarning:
18811891
1882-
dfc = dfc.copy()
1883-
dfc['A'][0] = 111
1884-
dfc
1892+
dfd = dfc.copy()
1893+
dfd['a'][2] = 111
1894+
dfd
18851895
1886-
This will **not** work at all, and so should be avoided:
1896+
Last, the subsequent example will **not** work at all, and so should be avoided:
18871897

18881898
::
18891899

18901900
>>> pd.set_option('mode.chained_assignment','raise')
1891-
>>> dfc.loc[0]['A'] = 1111
1901+
>>> dfd.loc[0]['a'] = 1111
18921902
Traceback (most recent call last)
18931903
...
18941904
SettingWithCopyException:

0 commit comments

Comments
 (0)