-
Notifications
You must be signed in to change notification settings - Fork 1
/
t.txt
1242 lines (1013 loc) · 58.3 KB
/
t.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
============================= test session starts ==============================
platform linux -- Python 3.6.6, pytest-4.0.0, py-1.7.0, pluggy-0.8.0 -- /home/finkernagel/upstream/dev/bin/python3
cachedir: .pytest_cache
rootdir: /home/finkernagel/upstream/dppd, inifile: setup.cfg
plugins: cov-2.6.0
collecting ... collected 155 items
tests/test_base.py::test_noop PASSED [ 0%]
tests/test_base.py::test_non_df_result PASSED [ 1%]
tests/test_base.py::test_nested_dp_pd_calls PASSED [ 1%]
tests/test_base.py::test_dp_pd_calls_nested_in_function_calls PASSED [ 2%]
tests/test_base.py::test_redefining_verb_vars PASSED [ 3%]
tests/test_base.py::test_redefining_alias_warns PASSED [ 3%]
tests/test_base.py::test_property_shadowed PASSED [ 4%]
tests/test_base.py::test_property_list_of_types PASSED [ 5%]
tests/test_base.py::test_verb_shadows_property PASSED [ 5%]
tests/test_base.py::test_register_verb_raises_on_non_identifier PASSED [ 6%]
tests/test_base.py::test_verb_returning_non_df PASSED [ 7%]
tests/test_base.py::test_no_context_manager_non_df_returning_verbs PASSED [ 7%]
tests/test_base.py::test_no_attribute_no_verb_raises_attribute_error PASSED [ 8%]
tests/test_base.py::test_no_attribute_no_verb_raises_attribute_error_context_manager PASSED [ 9%]
tests/test_base.py::test_dp_on_empty_stack_raises PASSED [ 9%]
tests/test_base.py::test_dp_continuation PASSED [ 10%]
tests/test_base.py::test_context_manager PASSED [ 10%]
tests/test_base.py::test_context_manager_with_non_df_args PASSED [ 11%]
tests/test_base.py::test_context_manager_totally_to_pandas PASSED [ 12%]
tests/test_base.py::test_interleaved_context_managers FAILED [ 12%]
tests/test_base.py::test_context_manager_chain PASSED [ 13%]
tests/test_base.py::test_mixing_context_manager_and_dp PASSED [ 14%]
tests/test_base.py::test_dppd_raises_on_non_dataframe PASSED [ 14%]
tests/test_base.py::test_straight_dp_raises PASSED [ 15%]
tests/test_base.py::test_forking PASSED [ 16%]
tests/test_base.py::test_forking_context_manager PASSED [ 16%]
tests/test_base.py::test_dp_on_dp PASSED [ 17%]
tests/test_base.py::test_descend_on_None_raises PASSED [ 18%]
tests/test_base.py::test_series_methods PASSED [ 18%]
tests/test_base.py::test_group_on_series_raises PASSED [ 19%]
tests/test_pandas_forwards.py::test_iloc PASSED [ 20%]
tests/test_pandas_forwards.py::test_loc PASSED [ 20%]
tests/test_pandas_forwards.py::test_loc_str PASSED [ 21%]
tests/test_pandas_forwards.py::test_loc_returning_series PASSED [ 21%]
tests/test_pandas_forwards.py::test_at PASSED [ 22%]
tests/test_pandas_forwards.py::test_iat PASSED [ 23%]
tests/test_pandas_forwards.py::test_sample PASSED [ 23%]
tests/test_pandas_forwards.py::test_index PASSED [ 24%]
tests/test_pandas_forwards.py::test_sort_values PASSED [ 25%]
tests/test_pandas_forwards.py::test_assign PASSED [ 25%]
tests/test_pandas_forwards.py::test_assign_in_order PASSED [ 26%]
tests/test_pandas_forwards.py::test_rename PASSED [ 27%]
tests/test_pandas_forwards.py::test_dataframe_subscript PASSED [ 27%]
tests/test_reshaping.py::test_basic_gather PASSED [ 28%]
tests/test_reshaping.py::test_gather_iris PASSED [ 29%]
tests/test_reshaping.py::test_basic_spread PASSED [ 29%]
tests/test_reshaping.py::test_spread_raises_on_multiple_keys PASSED [ 30%]
tests/test_reshaping.py::test_spread_raises_on_multiple_values PASSED [ 30%]
tests/test_reshaping.py::test_spread_raises_on_duplicate_values PASSED [ 31%]
tests/test_reshaping.py::test_seperate PASSED [ 32%]
tests/test_reshaping.py::test_seperate_and_remove PASSED [ 32%]
tests/test_reshaping.py::test_seperate_raises_on_Multip_column PASSED [ 33%]
tests/test_reshaping.py::test_unite PASSED [ 34%]
tests/test_reshaping.py::test_print FAILED [ 34%]
tests/test_select.py::test_select PASSED [ 35%]
tests/test_select.py::test_unselect PASSED [ 36%]
tests/test_select.py::test_select_list PASSED [ 36%]
tests/test_select.py::test_unselect_list PASSED [ 37%]
tests/test_select.py::test_select_X_Columns PASSED [ 38%]
tests/test_select.py::test_unselect_X_Columns PASSED [ 38%]
tests/test_select.py::test_select_mix_multiple PASSED [ 39%]
tests/test_select.py::test_unselect_mix_multiple PASSED [ 40%]
tests/test_select.py::test_select_columns_list_comprehension PASSED [ 40%]
tests/test_select.py::test_select_columns_str_operation PASSED [ 41%]
tests/test_select.py::test_unselect_columns_list_comprehension PASSED [ 41%]
tests/test_select.py::test_unselect_columns_str_operation PASSED [ 42%]
tests/test_select.py::test_select_renaming PASSED [ 43%]
tests/test_select.py::test_select_by_function PASSED [ 43%]
tests/test_select.py::test_select_regexps PASSED [ 44%]
tests/test_select.py::test_unselect_renaming_raises PASSED [ 45%]
tests/test_select.py::test_unselect_by_function PASSED [ 45%]
tests/test_select.py::test_unselect_regexps PASSED [ 46%]
tests/test_select.py::test_unselect_dict_raises PASSED [ 47%]
tests/test_select.py::test_select_invalid_column_spec PASSED [ 47%]
tests/test_select.py::test_select_inverse PASSED [ 48%]
tests/test_select.py::test_select_inverse_with_minus_column PASSED [ 49%]
tests/test_select.py::test_select_inverse_with_minus_column_and_normal_column PASSED [ 49%]
tests/test_select.py::test_select_inverse_list PASSED [ 50%]
tests/test_select.py::test_select_inverse_list_mix_raises PASSED [ 50%]
tests/test_select.py::test_unselect_inverse PASSED [ 51%]
tests/test_select.py::test_unselect_inverse_with_minus_column PASSED [ 52%]
tests/test_select.py::test_unselect_inverse_list PASSED [ 52%]
tests/test_select.py::test_unselect_inverse_list_mix_raises PASSED [ 53%]
tests/test_select.py::test_select_empty_list PASSED [ 54%]
tests/test_select.py::test_unselect_empty_list PASSED [ 54%]
tests/test_select.py::test_parse_column_spec_return_list_from_bool PASSED [ 55%]
tests/test_select.py::test_parse_column_spec_return_list_from_empty_list PASSED [ 56%]
tests/test_select.py::test_parse_column_spec_return_list_from_function PASSED [ 56%]
tests/test_select.py::test_parse_column_spec_return_list_from_regexps PASSED [ 57%]
tests/test_select.py::test_select_index PASSED [ 58%]
tests/test_select.py::test_select_dtypes PASSED [ 58%]
tests/test_single_verbs.py::test_head PASSED [ 59%]
tests/test_single_verbs.py::test_2_stage_concat PASSED [ 60%]
tests/test_single_verbs.py::test_list_concat PASSED [ 60%]
tests/test_single_verbs.py::test_arrange PASSED [ 61%]
tests/test_single_verbs.py::test_arrange_column_spec PASSED [ 61%]
tests/test_single_verbs.py::test_arrange_column_spec_empty PASSED [ 62%]
tests/test_single_verbs.py::test_arrange_column_spec_inverse PASSED [ 63%]
tests/test_single_verbs.py::test_arrange_kind_allowed PASSED [ 63%]
tests/test_single_verbs.py::test_arrange_column_spec_inverse2 PASSED [ 64%]
tests/test_single_verbs.py::test_mutate PASSED [ 65%]
tests/test_single_verbs.py::test_transmutate PASSED [ 65%]
tests/test_single_verbs.py::test_distinct_dataFrame PASSED [ 66%]
tests/test_single_verbs.py::test_distinct_series PASSED [ 67%]
tests/test_single_verbs.py::test_filter PASSED [ 67%]
tests/test_single_verbs.py::test_filter_combo PASSED [ 68%]
tests/test_single_verbs.py::test_group_by_add_count FAILED [ 69%]
tests/test_single_verbs.py::test_group_by_head FAILED [ 69%]
tests/test_single_verbs.py::test_group_by_ungroup_head FAILED [ 70%]
tests/test_single_verbs.py::test_ungroup_on_non_grouped_raises PASSED [ 70%]
tests/test_single_verbs.py::test_group_by_summarise FAILED [ 71%]
tests/test_single_verbs.py::test_sorting_within_groups FAILED [ 72%]
tests/test_single_verbs.py::test_sorting_within_groups_head FAILED [ 72%]
tests/test_single_verbs.py::test_sorting_within_groups_head_ungroup FAILED [ 73%]
tests/test_single_verbs.py::test_select_in_grouping_keeps_groups FAILED [ 74%]
tests/test_single_verbs.py::test_iter_groups FAILED [ 74%]
tests/test_single_verbs.py::test_grouped_mutate_returns_scalar FAILED [ 75%]
tests/test_single_verbs.py::test_grouped_mutate_returns_scalar_str FAILED [ 76%]
tests/test_single_verbs.py::test_grouped_mutate_returns_series FAILED [ 76%]
tests/test_single_verbs.py::test_grouped_mutate_function FAILED [ 77%]
tests/test_single_verbs.py::test_grouped_mutate_in_non_group PASSED [ 78%]
tests/test_single_verbs.py::test_grouped_mutate_repeated_keys FAILED [ 78%]
tests/test_single_verbs.py::test_grouped_reset_index FAILED [ 79%]
tests/test_single_verbs.py::test_grouped_mutate_non_sorted FAILED [ 80%]
tests/test_single_verbs.py::test_group_by_two_summarize_grouped FAILED [ 80%]
tests/test_single_verbs.py::test_group_by_two_mutate_grouped FAILED [ 81%]
tests/test_single_verbs.py::test_select_does_not_remove_group_columns FAILED [ 81%]
tests/test_single_verbs.py::test_unselected_group_columns_is_ignored FAILED [ 82%]
tests/test_single_verbs.py::test_dropping_group_columns_is_ignored FAILED [ 83%]
tests/test_single_verbs.py::test_accessor_drops_grouping FAILED [ 83%]
tests/test_single_verbs.py::test_groupby_sort_changes_order_but_not_result FAILED [ 84%]
tests/test_single_verbs.py::test_groupby_sort_changes_order_but_not_result2 FAILED [ 85%]
tests/test_single_verbs.py::test_grouped_mutate_missing_keys FAILED [ 85%]
tests/test_single_verbs.py::test_grouped_2_mutate_missing_keys FAILED [ 86%]
tests/test_single_verbs.py::test_basic_summary FAILED [ 87%]
tests/test_single_verbs.py::test_summary_quantiles FAILED [ 87%]
tests/test_single_verbs.py::test_summary_repeated_target_names PASSED [ 88%]
tests/test_single_verbs.py::test_empty_summarize_raises FAILED [ 89%]
tests/test_single_verbs.py::test_summarise_non_tuple FAILED [ 89%]
tests/test_single_verbs.py::test_summarize_auto_name FAILED [ 90%]
tests/test_single_verbs.py::test_do FAILED [ 90%]
tests/test_single_verbs.py::test_do_categorical_grouping FAILED [ 91%]
tests/test_single_verbs.py::test_do_without_group PASSED [ 92%]
tests/test_single_verbs.py::test_do_group2 FAILED [ 92%]
tests/test_single_verbs.py::test_filter_by_callable PASSED [ 93%]
tests/test_single_verbs.py::test_filter_by_converted_column PASSED [ 94%]
tests/test_single_verbs.py::test_filter_by_bool_column PASSED [ 94%]
tests/test_single_verbs.py::test_filter_by_column_raises_on_non_column PASSED [ 95%]
tests/test_single_verbs.py::test_filter_by_callable_grouped FAILED [ 96%]
tests/test_single_verbs.py::test_grouped_filter_by_returns_series FAILED [ 96%]
tests/test_single_verbs.py::test_filter_by_unkown_raises PASSED [ 97%]
tests/test_single_verbs.py::test_mutate_series PASSED [ 98%]
tests/test_single_verbs.py::test_groupby_select PASSED [ 98%]
tests/test_single_verbs.py::test_groupby_within_chain PASSED [ 99%]
tests/test_single_verbs.py::test_groupby_within_chain_select_on_group PASSED [100%]
=================================== FAILURES ===================================
______________________ test_interleaved_context_managers _______________________
def test_interleaved_context_managers():
with dppd(mtcars) as (dpX, X):
with dppd(diamonds) as (dpY, Y):
dpX.group_by("cyl")
dpY.filter_by(Y.cut == "Ideal")
dpX.summarize(("hp", np.mean, "mean_hp"))
dpY.summarize(("price", np.max, "max_price"))
should_X = (
mtcars.groupby("cyl")[["hp"]].agg(np.mean).rename(columns={"hp": "mean_hp"})
).reset_index()
should_Y = (
pd.DataFrame(diamonds[diamonds.cut == "Ideal"].max()[["price"]])
.transpose()
.rename(columns={"price": "max_price"})
)
should_Y["max_price"] = should_Y["max_price"].astype(int)
> assert_frame_equal(X, should_X)
tests/test_base.py:226:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../dev/lib/python3.6/site-packages/pandas/util/testing.py:1321: in assert_frame_equal
'{shape!r}'.format(shape=right.shape))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
obj = 'DataFrame', message = 'DataFrame shape mismatch', left = '(1, 1)'
right = '(3, 2)', diff = None
def raise_assert_detail(obj, message, left, right, diff=None):
if isinstance(left, np.ndarray):
left = pprint_thing(left)
elif is_categorical_dtype(left):
left = repr(left)
if PY2 and isinstance(left, string_types):
# left needs to be printable in native text type in python2
left = left.encode('utf-8')
if isinstance(right, np.ndarray):
right = pprint_thing(right)
elif is_categorical_dtype(right):
right = repr(right)
if PY2 and isinstance(right, string_types):
# right needs to be printable in native text type in python2
right = right.encode('utf-8')
msg = """{obj} are different
{message}
[left]: {left}
[right]: {right}""".format(obj=obj, message=message, left=left, right=right)
if diff is not None:
msg += "\n[diff]: {diff}".format(diff=diff)
> raise AssertionError(msg)
E AssertionError: DataFrame are different
E
E DataFrame shape mismatch
E [left]: (1, 1)
E [right]: (3, 2)
../dev/lib/python3.6/site-packages/pandas/util/testing.py:1035: AssertionError
__________________________________ test_print __________________________________
capsys = <_pytest.capture.CaptureFixture object at 0x7f7ddc22d860>
def test_print(capsys):
dp(mtcars).print()
captured = capsys.readouterr()
assert "Mazda RX4" in captured.out
> dp(mtcars).group_by("cyl").print()
tests/test_reshaping.py:161:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pandas.core.groupby.groupby.DataFrameGroupBy object at 0x7f7ddbfcd5f8>
attr = 'print'
def __getattr__(self, attr):
if attr in self._internal_names_set:
return object.__getattribute__(self, attr)
if attr in self.obj:
return self[attr]
if hasattr(self.obj, attr):
return self._make_wrapper(attr)
raise AttributeError("%r object has no attribute %r" %
> (type(self).__name__, attr))
E AttributeError: 'DataFrameGroupBy' object has no attribute 'print'
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:765: AttributeError
___________________________ test_group_by_add_count ____________________________
def test_group_by_add_count():
df = pd.DataFrame({"x": [1, 5, 2, 2, 4, 0, 4], "y": [1, 2, 3, 4, 5, 6, 5]})
> actual = dp(df).group_by("x").add_count().pd
tests/test_single_verbs.py:143:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pandas.core.groupby.groupby.DataFrameGroupBy object at 0x7f7ddc248160>
attr = 'add_count'
def __getattr__(self, attr):
if attr in self._internal_names_set:
return object.__getattribute__(self, attr)
if attr in self.obj:
return self[attr]
if hasattr(self.obj, attr):
return self._make_wrapper(attr)
raise AttributeError("%r object has no attribute %r" %
> (type(self).__name__, attr))
E AttributeError: 'DataFrameGroupBy' object has no attribute 'add_count'
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:765: AttributeError
______________________________ test_group_by_head ______________________________
def test_group_by_head():
> actual = dp(mtcars).group_by("cyl").head(1).select("name").pd
tests/test_single_verbs.py:156:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../dev/lib/python3.6/site-packages/pandas/core/generic.py:3052: in select
np.asarray([bool(crit(label)) for label in axis_values])]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.0 = <list_iterator object at 0x7f7ddc2b6dd8>
> np.asarray([bool(crit(label)) for label in axis_values])]
E TypeError: 'str' object is not callable
../dev/lib/python3.6/site-packages/pandas/core/generic.py:3052: TypeError
__________________________ test_group_by_ungroup_head __________________________
def test_group_by_ungroup_head():
> actual = dp(mtcars).group_by("cyl").identity().ungroup().head(1).pd
tests/test_single_verbs.py:169:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pandas.core.groupby.groupby.DataFrameGroupBy object at 0x7f7ddc31dc88>
attr = 'identity'
def __getattr__(self, attr):
if attr in self._internal_names_set:
return object.__getattribute__(self, attr)
if attr in self.obj:
return self[attr]
if hasattr(self.obj, attr):
return self._make_wrapper(attr)
raise AttributeError("%r object has no attribute %r" %
> (type(self).__name__, attr))
E AttributeError: 'DataFrameGroupBy' object has no attribute 'identity'
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:765: AttributeError
___________________________ test_group_by_summarise ____________________________
def test_group_by_summarise():
> actual = dp(mtcars).group_by("cyl").summarise(("name", len, "count")).pd
tests/test_single_verbs.py:181:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pandas.core.groupby.groupby.DataFrameGroupBy object at 0x7f7df44a76a0>
attr = 'summarise'
def __getattr__(self, attr):
if attr in self._internal_names_set:
return object.__getattribute__(self, attr)
if attr in self.obj:
return self[attr]
if hasattr(self.obj, attr):
return self._make_wrapper(attr)
raise AttributeError("%r object has no attribute %r" %
> (type(self).__name__, attr))
E AttributeError: 'DataFrameGroupBy' object has no attribute 'summarise'
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:765: AttributeError
__________________________ test_sorting_within_groups __________________________
def test_sorting_within_groups():
> actual = dp(mtcars).group_by(X.cyl).sort_values("qsec").pd
tests/test_single_verbs.py:191:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:762: in __getattr__
return self._make_wrapper(attr)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pandas.core.groupby.groupby.DataFrameGroupBy object at 0x7f7ddc2b6dd8>
name = 'sort_values'
def _make_wrapper(self, name):
if name not in self._apply_whitelist:
is_callable = callable(getattr(self._selected_obj, name, None))
kind = ' callable ' if is_callable else ' '
msg = ("Cannot access{0}attribute {1!r} of {2!r} objects, try "
"using the 'apply' method".format(kind, name,
type(self).__name__))
> raise AttributeError(msg)
E AttributeError: Cannot access callable attribute 'sort_values' of 'DataFrameGroupBy' objects, try using the 'apply' method
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:799: AttributeError
_______________________ test_sorting_within_groups_head ________________________
def test_sorting_within_groups_head():
> actual = dp(mtcars).group_by(X.cyl).sort_values("qsec").tail(1).pd
tests/test_single_verbs.py:198:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:762: in __getattr__
return self._make_wrapper(attr)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pandas.core.groupby.groupby.DataFrameGroupBy object at 0x7f7ddc31dc88>
name = 'sort_values'
def _make_wrapper(self, name):
if name not in self._apply_whitelist:
is_callable = callable(getattr(self._selected_obj, name, None))
kind = ' callable ' if is_callable else ' '
msg = ("Cannot access{0}attribute {1!r} of {2!r} objects, try "
"using the 'apply' method".format(kind, name,
type(self).__name__))
> raise AttributeError(msg)
E AttributeError: Cannot access callable attribute 'sort_values' of 'DataFrameGroupBy' objects, try using the 'apply' method
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:799: AttributeError
___________________ test_sorting_within_groups_head_ungroup ____________________
def test_sorting_within_groups_head_ungroup():
> actual = dp(mtcars).group_by(X.cyl).sort_values("qsec").ungroup().tail(1).pd
tests/test_single_verbs.py:208:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:762: in __getattr__
return self._make_wrapper(attr)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pandas.core.groupby.groupby.DataFrameGroupBy object at 0x7f7ddc33fc88>
name = 'sort_values'
def _make_wrapper(self, name):
if name not in self._apply_whitelist:
is_callable = callable(getattr(self._selected_obj, name, None))
kind = ' callable ' if is_callable else ' '
msg = ("Cannot access{0}attribute {1!r} of {2!r} objects, try "
"using the 'apply' method".format(kind, name,
type(self).__name__))
> raise AttributeError(msg)
E AttributeError: Cannot access callable attribute 'sort_values' of 'DataFrameGroupBy' objects, try using the 'apply' method
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:799: AttributeError
_____________________ test_select_in_grouping_keeps_groups _____________________
def test_select_in_grouping_keeps_groups():
> actual = dp(mtcars).group_by("cyl").select("qsec").pd
tests/test_single_verbs.py:216:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:762: in __getattr__
return self._make_wrapper(attr)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pandas.core.groupby.groupby.DataFrameGroupBy object at 0x7f7ddc26d780>
name = 'select'
def _make_wrapper(self, name):
if name not in self._apply_whitelist:
is_callable = callable(getattr(self._selected_obj, name, None))
kind = ' callable ' if is_callable else ' '
msg = ("Cannot access{0}attribute {1!r} of {2!r} objects, try "
"using the 'apply' method".format(kind, name,
type(self).__name__))
> raise AttributeError(msg)
E AttributeError: Cannot access callable attribute 'select' of 'DataFrameGroupBy' objects, try using the 'apply' method
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:799: AttributeError
_______________________________ test_iter_groups _______________________________
def test_iter_groups():
g = []
ls = []
> for grp, sub_df in dp(mtcars).group_by("cyl").itergroups():
tests/test_single_verbs.py:223:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pandas.core.groupby.groupby.DataFrameGroupBy object at 0x7f7ddc31dc88>
attr = 'itergroups'
def __getattr__(self, attr):
if attr in self._internal_names_set:
return object.__getattribute__(self, attr)
if attr in self.obj:
return self[attr]
if hasattr(self.obj, attr):
return self._make_wrapper(attr)
raise AttributeError("%r object has no attribute %r" %
> (type(self).__name__, attr))
E AttributeError: 'DataFrameGroupBy' object has no attribute 'itergroups'
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:765: AttributeError
______________________ test_grouped_mutate_returns_scalar ______________________
def test_grouped_mutate_returns_scalar():
actual = (
dp(mtcars)
> .group_by("cyl")
.mutate(count={grp: len(sub_df) for (grp, sub_df) in X.itergroups()})
.select("count")
.pd.sort_index()
)
tests/test_single_verbs.py:233:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pandas.core.groupby.groupby.DataFrameGroupBy object at 0x7f7ddc248438>
attr = 'mutate'
def __getattr__(self, attr):
if attr in self._internal_names_set:
return object.__getattribute__(self, attr)
if attr in self.obj:
return self[attr]
if hasattr(self.obj, attr):
return self._make_wrapper(attr)
raise AttributeError("%r object has no attribute %r" %
> (type(self).__name__, attr))
E AttributeError: 'DataFrameGroupBy' object has no attribute 'mutate'
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:765: AttributeError
____________________ test_grouped_mutate_returns_scalar_str ____________________
def test_grouped_mutate_returns_scalar_str():
actual = (
dp(mtcars)
> .group_by("cyl")
.mutate(count={grp: "X" + str(len(sub_df)) for (grp, sub_df) in X.itergroups()})
.select("count")
.pd.sort_index()
)
tests/test_single_verbs.py:249:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pandas.core.groupby.groupby.DataFrameGroupBy object at 0x7f7ddbf07be0>
attr = 'mutate'
def __getattr__(self, attr):
if attr in self._internal_names_set:
return object.__getattribute__(self, attr)
if attr in self.obj:
return self[attr]
if hasattr(self.obj, attr):
return self._make_wrapper(attr)
raise AttributeError("%r object has no attribute %r" %
> (type(self).__name__, attr))
E AttributeError: 'DataFrameGroupBy' object has no attribute 'mutate'
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:765: AttributeError
______________________ test_grouped_mutate_returns_series ______________________
def test_grouped_mutate_returns_series():
actual = (
dp(mtcars)
> .group_by("cyl")
.mutate(grp_rank={grp: sub_df.hp.rank() for (grp, sub_df) in X.itergroups()})
.select("grp_rank")
.pd.sort_index()
)
tests/test_single_verbs.py:265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pandas.core.groupby.groupby.DataFrameGroupBy object at 0x7f7ddc265eb8>
attr = 'mutate'
def __getattr__(self, attr):
if attr in self._internal_names_set:
return object.__getattribute__(self, attr)
if attr in self.obj:
return self[attr]
if hasattr(self.obj, attr):
return self._make_wrapper(attr)
raise AttributeError("%r object has no attribute %r" %
> (type(self).__name__, attr))
E AttributeError: 'DataFrameGroupBy' object has no attribute 'mutate'
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:765: AttributeError
_________________________ test_grouped_mutate_function _________________________
def test_grouped_mutate_function():
actual = (
dp(mtcars)
> .group_by("cyl")
.mutate(max_hp=lambda x: x["hp"].max())
.select(["cyl", "max_hp", "name"])
.pd
)
tests/test_single_verbs.py:282:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pandas.core.groupby.groupby.DataFrameGroupBy object at 0x7f7ddc265c50>
attr = 'mutate'
def __getattr__(self, attr):
if attr in self._internal_names_set:
return object.__getattribute__(self, attr)
if attr in self.obj:
return self[attr]
if hasattr(self.obj, attr):
return self._make_wrapper(attr)
raise AttributeError("%r object has no attribute %r" %
> (type(self).__name__, attr))
E AttributeError: 'DataFrameGroupBy' object has no attribute 'mutate'
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:765: AttributeError
______________________ test_grouped_mutate_repeated_keys _______________________
def test_grouped_mutate_repeated_keys():
df = mtcars.copy()
df.index = list(range(16)) + list(range(16))
should = df.assign(grp_rank=df.groupby("cyl")["hp"].rank())[
["cyl", "name", "grp_rank"]
].sort_values("name")
with dppd(df) as (ddf, X):
actual = (
> ddf.group_by("cyl")
.mutate(
grp_rank={grp: sub_df.hp.rank() for (grp, sub_df) in X.itergroups()}
)
.select(["name", "grp_rank"])
.sort_index()
)
tests/test_single_verbs.py:315:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pandas.core.groupby.groupby.DataFrameGroupBy object at 0x7f7ddbd4e240>
attr = 'mutate'
def __getattr__(self, attr):
if attr in self._internal_names_set:
return object.__getattribute__(self, attr)
if attr in self.obj:
return self[attr]
if hasattr(self.obj, attr):
return self._make_wrapper(attr)
raise AttributeError("%r object has no attribute %r" %
> (type(self).__name__, attr))
E AttributeError: 'DataFrameGroupBy' object has no attribute 'mutate'
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:765: AttributeError
___________________________ test_grouped_reset_index ___________________________
def test_grouped_reset_index():
> actual = dp(mtcars).group_by("cyl").reset_index().pd
tests/test_single_verbs.py:345:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:762: in __getattr__
return self._make_wrapper(attr)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pandas.core.groupby.groupby.DataFrameGroupBy object at 0x7f7ddbf074e0>
name = 'reset_index'
def _make_wrapper(self, name):
if name not in self._apply_whitelist:
is_callable = callable(getattr(self._selected_obj, name, None))
kind = ' callable ' if is_callable else ' '
msg = ("Cannot access{0}attribute {1!r} of {2!r} objects, try "
"using the 'apply' method".format(kind, name,
type(self).__name__))
> raise AttributeError(msg)
E AttributeError: Cannot access callable attribute 'reset_index' of 'DataFrameGroupBy' objects, try using the 'apply' method
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:799: AttributeError
________________________ test_grouped_mutate_non_sorted ________________________
def test_grouped_mutate_non_sorted():
actual = (
dp(mtcars)
> .group_by("cyl")
.mutate(grp_rank={grp: sub_df.hp.rank() for (grp, sub_df) in X.itergroups()})
.select("grp_rank")
.pd.sort_index()
)
tests/test_single_verbs.py:356:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pandas.core.groupby.groupby.DataFrameGroupBy object at 0x7f7ddc265b00>
attr = 'mutate'
def __getattr__(self, attr):
if attr in self._internal_names_set:
return object.__getattribute__(self, attr)
if attr in self.obj:
return self[attr]
if hasattr(self.obj, attr):
return self._make_wrapper(attr)
raise AttributeError("%r object has no attribute %r" %
> (type(self).__name__, attr))
E AttributeError: 'DataFrameGroupBy' object has no attribute 'mutate'
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:765: AttributeError
_____________________ test_group_by_two_summarize_grouped ______________________
def test_group_by_two_summarize_grouped():
> actual = dp(diamonds).group_by("color", "cut").summarise(("price", len, "count")).pd
tests/test_single_verbs.py:371:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pandas.core.groupby.groupby.DataFrameGroupBy object at 0x7f7ddc265eb8>
attr = 'summarise'
def __getattr__(self, attr):
if attr in self._internal_names_set:
return object.__getattribute__(self, attr)
if attr in self.obj:
return self[attr]
if hasattr(self.obj, attr):
return self._make_wrapper(attr)
raise AttributeError("%r object has no attribute %r" %
> (type(self).__name__, attr))
E AttributeError: 'DataFrameGroupBy' object has no attribute 'summarise'
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:765: AttributeError
_______________________ test_group_by_two_mutate_grouped _______________________
def test_group_by_two_mutate_grouped():
actual = (
dp(mtcars)
> .group_by("cyl", "vs")
.mutate(grp_rank={grp: sub_df.hp.rank() for (grp, sub_df) in X.itergroups()})
.select("grp_rank")
.pd.sort_index()
)
tests/test_single_verbs.py:381:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pandas.core.groupby.groupby.DataFrameGroupBy object at 0x7f7ddc248fd0>
attr = 'mutate'
def __getattr__(self, attr):
if attr in self._internal_names_set:
return object.__getattribute__(self, attr)
if attr in self.obj:
return self[attr]
if hasattr(self.obj, attr):
return self._make_wrapper(attr)
raise AttributeError("%r object has no attribute %r" %
> (type(self).__name__, attr))
E AttributeError: 'DataFrameGroupBy' object has no attribute 'mutate'
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:765: AttributeError
__________________ test_select_does_not_remove_group_columns ___________________
def test_select_does_not_remove_group_columns():
> actual = dp(mtcars).group_by("cyl").select("name").pd
tests/test_single_verbs.py:396:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:762: in __getattr__
return self._make_wrapper(attr)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pandas.core.groupby.groupby.DataFrameGroupBy object at 0x7f7ddc248cc0>
name = 'select'
def _make_wrapper(self, name):
if name not in self._apply_whitelist:
is_callable = callable(getattr(self._selected_obj, name, None))
kind = ' callable ' if is_callable else ' '
msg = ("Cannot access{0}attribute {1!r} of {2!r} objects, try "
"using the 'apply' method".format(kind, name,
type(self).__name__))
> raise AttributeError(msg)
E AttributeError: Cannot access callable attribute 'select' of 'DataFrameGroupBy' objects, try using the 'apply' method
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:799: AttributeError
___________________ test_unselected_group_columns_is_ignored ___________________
def test_unselected_group_columns_is_ignored():
> actual = dp(mtcars).group_by("cyl").unselect("cyl").pd
tests/test_single_verbs.py:401:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pandas.core.groupby.groupby.DataFrameGroupBy object at 0x7f7ddbf07ef0>
attr = 'unselect'
def __getattr__(self, attr):
if attr in self._internal_names_set:
return object.__getattribute__(self, attr)
if attr in self.obj:
return self[attr]
if hasattr(self.obj, attr):
return self._make_wrapper(attr)
raise AttributeError("%r object has no attribute %r" %
> (type(self).__name__, attr))
E AttributeError: 'DataFrameGroupBy' object has no attribute 'unselect'
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:765: AttributeError
____________________ test_dropping_group_columns_is_ignored ____________________
def test_dropping_group_columns_is_ignored():
> actual = dp(mtcars).group_by("cyl").drop("cyl", axis=1).pd
tests/test_single_verbs.py:406:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:762: in __getattr__
return self._make_wrapper(attr)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pandas.core.groupby.groupby.DataFrameGroupBy object at 0x7f7ddc255ba8>
name = 'drop'
def _make_wrapper(self, name):
if name not in self._apply_whitelist:
is_callable = callable(getattr(self._selected_obj, name, None))
kind = ' callable ' if is_callable else ' '
msg = ("Cannot access{0}attribute {1!r} of {2!r} objects, try "
"using the 'apply' method".format(kind, name,
type(self).__name__))
> raise AttributeError(msg)
E AttributeError: Cannot access callable attribute 'drop' of 'DataFrameGroupBy' objects, try using the 'apply' method
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:799: AttributeError
_________________________ test_accessor_drops_grouping _________________________
def test_accessor_drops_grouping():
> actual = dp(mtcars).group_by("cyl").loc[:, ["name"]]
tests/test_single_verbs.py:411:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:762: in __getattr__
return self._make_wrapper(attr)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pandas.core.groupby.groupby.DataFrameGroupBy object at 0x7f7ddbd9e390>
name = 'loc'
def _make_wrapper(self, name):
if name not in self._apply_whitelist:
is_callable = callable(getattr(self._selected_obj, name, None))
kind = ' callable ' if is_callable else ' '
msg = ("Cannot access{0}attribute {1!r} of {2!r} objects, try "
"using the 'apply' method".format(kind, name,
type(self).__name__))
> raise AttributeError(msg)
E AttributeError: Cannot access callable attribute 'loc' of 'DataFrameGroupBy' objects, try using the 'apply' method
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:799: AttributeError
________________ test_groupby_sort_changes_order_but_not_result ________________
def test_groupby_sort_changes_order_but_not_result():
a = (
dp(mtcars)
> .group_by("cyl")
.sort_values("hp")
.mutate(count={grp: len(sub_df) for (grp, sub_df) in X.itergroups()})
.pd
)
tests/test_single_verbs.py:421:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:762: in __getattr__
return self._make_wrapper(attr)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pandas.core.groupby.groupby.DataFrameGroupBy object at 0x7f7ddc20a278>
name = 'sort_values'
def _make_wrapper(self, name):
if name not in self._apply_whitelist:
is_callable = callable(getattr(self._selected_obj, name, None))
kind = ' callable ' if is_callable else ' '
msg = ("Cannot access{0}attribute {1!r} of {2!r} objects, try "
"using the 'apply' method".format(kind, name,
type(self).__name__))
> raise AttributeError(msg)
E AttributeError: Cannot access callable attribute 'sort_values' of 'DataFrameGroupBy' objects, try using the 'apply' method
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:799: AttributeError
_______________ test_groupby_sort_changes_order_but_not_result2 ________________
def test_groupby_sort_changes_order_but_not_result2():
a = (
dp(mtcars)
> .group_by("cyl")
.sort_values("hp")
.mutate(count={grp: sub_df.hp.rank() for (grp, sub_df) in X.itergroups()})
.pd
)
tests/test_single_verbs.py:438:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:762: in __getattr__
return self._make_wrapper(attr)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pandas.core.groupby.groupby.DataFrameGroupBy object at 0x7f7ddba19358>
name = 'sort_values'
def _make_wrapper(self, name):
if name not in self._apply_whitelist:
is_callable = callable(getattr(self._selected_obj, name, None))
kind = ' callable ' if is_callable else ' '
msg = ("Cannot access{0}attribute {1!r} of {2!r} objects, try "
"using the 'apply' method".format(kind, name,
type(self).__name__))
> raise AttributeError(msg)
E AttributeError: Cannot access callable attribute 'sort_values' of 'DataFrameGroupBy' objects, try using the 'apply' method
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:799: AttributeError
_______________________ test_grouped_mutate_missing_keys _______________________
def test_grouped_mutate_missing_keys():
> actual = dp(mtcars).group_by("cyl").mutate(count={4: 170, 6: 180, 8: 190}).pd
tests/test_single_verbs.py:453:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pandas.core.groupby.groupby.DataFrameGroupBy object at 0x7f7ddc248f28>
attr = 'mutate'
def __getattr__(self, attr):
if attr in self._internal_names_set:
return object.__getattribute__(self, attr)
if attr in self.obj:
return self[attr]
if hasattr(self.obj, attr):
return self._make_wrapper(attr)
raise AttributeError("%r object has no attribute %r" %
> (type(self).__name__, attr))
E AttributeError: 'DataFrameGroupBy' object has no attribute 'mutate'
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:765: AttributeError
______________________ test_grouped_2_mutate_missing_keys ______________________
def test_grouped_2_mutate_missing_keys():
counts = {(4, 0): 40, (4, 1): 41, (6, 0): 60, (6, 1): 61, (8, 0): 80, (8, 1): 81}
> actual = dp(mtcars).group_by("cyl", "vs").mutate(count=counts).pd
tests/test_single_verbs.py:462:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pandas.core.groupby.groupby.DataFrameGroupBy object at 0x7f7ddc248fd0>
attr = 'mutate'
def __getattr__(self, attr):
if attr in self._internal_names_set:
return object.__getattribute__(self, attr)
if attr in self.obj:
return self[attr]
if hasattr(self.obj, attr):
return self._make_wrapper(attr)
raise AttributeError("%r object has no attribute %r" %
> (type(self).__name__, attr))
E AttributeError: 'DataFrameGroupBy' object has no attribute 'mutate'
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:765: AttributeError
______________________________ test_basic_summary ______________________________
def test_basic_summary():
> actual = dp(mtcars).group_by("cyl").summarize((X.hp, len, "count")).pd
tests/test_single_verbs.py:476:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pandas.core.groupby.groupby.DataFrameGroupBy object at 0x7f7ddbd31630>
attr = 'summarize'
def __getattr__(self, attr):
if attr in self._internal_names_set:
return object.__getattribute__(self, attr)
if attr in self.obj:
return self[attr]
if hasattr(self.obj, attr):
return self._make_wrapper(attr)
raise AttributeError("%r object has no attribute %r" %
> (type(self).__name__, attr))
E AttributeError: 'DataFrameGroupBy' object has no attribute 'summarize'
../dev/lib/python3.6/site-packages/pandas/core/groupby/groupby.py:765: AttributeError
____________________________ test_summary_quantiles ____________________________
def test_summary_quantiles():
args = [
("disp", lambda x, q=q: x.quantile(q), "q%.2f" % q)
for q in np.arange(0, 1.1, 0.1)
]
> actual = dp(mtcars).sort_values("cyl").group_by("cyl").summarise(*args).pd
tests/test_single_verbs.py:488:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pandas.core.groupby.groupby.DataFrameGroupBy object at 0x7f7ddbd4eef0>
attr = 'summarise'
def __getattr__(self, attr):
if attr in self._internal_names_set:
return object.__getattribute__(self, attr)
if attr in self.obj:
return self[attr]
if hasattr(self.obj, attr):
return self._make_wrapper(attr)
raise AttributeError("%r object has no attribute %r" %
> (type(self).__name__, attr))
E AttributeError: 'DataFrameGroupBy' object has no attribute 'summarise'