Skip to content

Commit cd17104

Browse files
committed
Merge branch 'master' into bugfix/string-timedelta2
Fix linting issues, change single quotes to double quotes, add 'ns' to timedelta string.
2 parents b8031c2 + 043b609 commit cd17104

File tree

94 files changed

+4189
-2874
lines changed

Some content is hidden

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

94 files changed

+4189
-2874
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

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/merging.rst

+64-3
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,18 @@
1010
p = doctools.TablePlotter()
1111
1212
13-
****************************
14-
Merge, join, and concatenate
15-
****************************
13+
************************************
14+
Merge, join, concatenate and compare
15+
************************************
1616

1717
pandas provides various facilities for easily combining together Series or
1818
DataFrame with various kinds of set logic for the indexes
1919
and relational algebra functionality in the case of join / merge-type
2020
operations.
2121

22+
In addition, pandas also provides utilities to compare two Series or DataFrame
23+
and summarize their differences.
24+
2225
.. _merging.concat:
2326

2427
Concatenating objects
@@ -1477,3 +1480,61 @@ exclude exact matches on time. Note that though we exclude the exact matches
14771480
by='ticker',
14781481
tolerance=pd.Timedelta('10ms'),
14791482
allow_exact_matches=False)
1483+
1484+
.. _merging.compare:
1485+
1486+
Comparing objects
1487+
-----------------
1488+
1489+
The :meth:`~Series.compare` and :meth:`~DataFrame.compare` methods allow you to
1490+
compare two DataFrame or Series, respectively, and summarize their differences.
1491+
1492+
This feature was added in :ref:`V1.1.0 <whatsnew_110.dataframe_or_series_comparing>`.
1493+
1494+
For example, you might want to compare two `DataFrame` and stack their differences
1495+
side by side.
1496+
1497+
.. ipython:: python
1498+
1499+
df = pd.DataFrame(
1500+
{
1501+
"col1": ["a", "a", "b", "b", "a"],
1502+
"col2": [1.0, 2.0, 3.0, np.nan, 5.0],
1503+
"col3": [1.0, 2.0, 3.0, 4.0, 5.0]
1504+
},
1505+
columns=["col1", "col2", "col3"],
1506+
)
1507+
df
1508+
1509+
.. ipython:: python
1510+
1511+
df2 = df.copy()
1512+
df2.loc[0, 'col1'] = 'c'
1513+
df2.loc[2, 'col3'] = 4.0
1514+
df2
1515+
1516+
.. ipython:: python
1517+
1518+
df.compare(df2)
1519+
1520+
By default, if two corresponding values are equal, they will be shown as ``NaN``.
1521+
Furthermore, if all values in an entire row / column, the row / column will be
1522+
omitted from the result. The remaining differences will be aligned on columns.
1523+
1524+
If you wish, you may choose to stack the differences on rows.
1525+
1526+
.. ipython:: python
1527+
1528+
df.compare(df2, align_axis=0)
1529+
1530+
If you wish to keep all original rows and columns, set `keep_shape` argument
1531+
to ``True``.
1532+
1533+
.. ipython:: python
1534+
1535+
df.compare(df2, keep_shape=True)
1536+
1537+
You may also keep all the original values even if they are equal.
1538+
1539+
.. ipython:: python
1540+
df.compare(df2, keep_shape=True, keep_equal=True)

0 commit comments

Comments
 (0)