File size: 134,357 Bytes
05e1fa1 58ba0ab 05e1fa1 58ba0ab 05e1fa1 58ba0ab 05e1fa1 58ba0ab 05e1fa1 |
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 1001 1002 |
ã¢ã¯ã¢è²ã§æ£åžå³ãæç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, color='aqua') plt.scatter(ããŒã¿åx, ããŒã¿åy, color='aqua')
ããŒã¿ãã¬ãŒã ã®æ¬ æå€ãå¹³åå€ã«å€æŽãã df.fillna(df.mean()) df.fillna(df.mean())
option: ãããŒã©ã«ãã¯ã€ããçšãã color = 'floralwhite' color = 'floralwhite'
option: ããŒã¯ããŒã³ã¿ã«ãã©ã³ãã®è²ãå€æŽãã color = 'darkmagenta' color = 'darkmagenta'
è¡åã®åããšã®æ倧 np.max(aArray, axis=0) np.max(aArray, axis=0)
æ£åžå³ã®ãã€ã¢ã¢ã³ãå°ã®è²ãèšå®ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='D', markerfacecolor='#800080') plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='D', markerfacecolor='#800080')
ããŒã¿ãã¬ãŒã ã®äžéšã®åã®æ¬ æå€ãå¹³åå€ã«å€æŽãã df[['åA', 'åB']].fillna(df[['åA', 'åB']].mean()) df[['åA', 'åB']].fillna(df[['åA', 'åB']].mean())
ããŒã¿ãã¬ãŒã ã®æ¬ æå€ãåŸã®è¡ã®å€ã«èšå®ãã df[df.fillna(method='bfill') df.fillna(method='bfill')
åæ¹åãã¥ãŒã®äžã«æŽæ°ãå«ãŸããŠãã調ã¹ã æŽæ° in 䞡端ãã¥ãŒ æŽæ° in 䞡端ãã¥ãŒ
xãèšå·ã«ãã x = sympy.Symbol('x') x = sympy.Symbol('x')
ããŒãèŸæžã«ååšãã ã㌠not in èŸæž ã㌠not in èŸæž
æŽæ°ã®ç¡éãªã€ãã¬ãŒã¿ itertools.repeat(æŽæ°) itertools.repeat(æŽæ°)
option: ããã£ã¢ã ã¿ãŒã³ã€ãºã䜿ã color ='mediumturquoise' color = 'mediumturquoise'
æå®ãããåãªã¹ãã€ããŠãããŒã¿ãã¬ãŒã ã®éè€ã確èªãã df.duplicated(subset=['åA', 'åB']) df.duplicated(subset=['åA', 'åB'])
èµ€ãäžžããŒã«ãŒãæ£åžå³ã«çšãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='o', c='r') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='o', c='r')
å°æ°ç¹æ°ã®éäœåŒŠ x = 0.33<nl>math.acos(x) x = 0.33<nl>math.acos(x)
æ£åžå³ãã¹ããªã³ã°ã°ãªãŒã³è²ãšããŠæç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, color='springgreen') plt.scatter(ããŒã¿åx, ããŒã¿åy, color='springgreen')
option: ãªãã³ã«ãã©ã³ãã®è²ãèšå®ãã color = 'linen' color = 'linen'
æ£åžå³ã«éãäžè§å°ãæç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='^', markerfacecolor='b') plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='^', markerfacecolor='b')
ã»ããã空ãå€å®ãã len(ã»ãã) == 0 len(ã»ãã) == 0
æãç·ã°ã©ããéãç¹ç·ã䜿ã£ãŠæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dotted', color='b') plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dotted', color='b')
æ£ã°ã©ãã®è²ãããŒã¯ã¬ããã«ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='darkred') plt.bar(ããŒã¿åx, ããŒã¿åy, color='darkred')
æ£ã°ã©ããã¬ã¢ã³ã·ãã©ã³è²ãšããŠæç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='lemonchiffon') plt.bar(ããŒã¿åx, ããŒã¿åy, color='lemonchiffon')
ïŒã€ã®åã§ããŒã¿ãã¬ãŒã ãã°ã«ãŒãåããããåæãã [(name, group_df) for name, group_df in df.groupby(['åA', 'åB'])] [(name, group_df) for name, group_df in df.groupby(['åA', 'åB'])]
æååãæåã®ã»ãã¬ãŒã¿ã§äºåããŠãåŸãã®æ¹ã䜿ã æåå.partition(ã»ãã¬ãŒã¿)[-1] æåå.partition(ã»ãã¬ãŒã¿)[-1]
ã©ã€ã è²ãçšããŠæ£ã°ã©ããæç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='lime') plt.bar(ããŒã¿åx, ããŒã¿åy, color='lime')
option: ããŒã¯ã·ã¢ã°ãªãŒã³ã«ã°ã©ãã®è²ãèšå®ãã color = 'darkseagreen' color = 'darkseagreen'
ããŒã¿ãJSON圢åŒãšããŠãã¡ã€ã«ã«åºåãã json.dump(ããŒã¿, ãã¡ã€ã«åºå, ensure_ascii=False) with open('file.json', 'w') as f:<nl><tab>json.dump(ããŒã¿, f, ensure_ascii=False)
ãµãã€ã®åãçµã¿åãããŠã°ã«ãŒãåããåèšãæ±ãã df.groupby(['åA', 'åB'], as_index=False).sum() df.groupby(['åA', 'åB'], as_index=False).sum()
æ°åãšæ°åã®æ£åžå³ãæããŠæããŒã«ãŒã®è²ãrgbã«èšå®ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='*', c=rgb) plt.plot(ããŒã¿åx, ããŒã¿åy, marker='*', c=rgb)
ãã¹ãã°ã©ã ã®è²ãã·ãŒã°ãªãŒã³ã«æå®ãã plt.hist(ããŒã¿å, color='seagreen') plt.hist(ããŒã¿å, color='seagreen')
ããŒã¿ãã¬ãŒã ã2ã€ã®åã§æé ã«ç Žå£çã«ãœãŒããã df.sort_values(by=['åA', 'åB'], ascending=True, inplace=True) df.sort_values(by=['åA', 'åB'], ascending=True, inplace=True)
Kæè¿åæ³ã§ã¯ã©ã¹åé¡ããã model = sklearn.neighbors.KNeighborsClassifier(n_neighbors=5) model = sklearn.neighbors.KNeighborsClassifier(n_neighbors=5)
2ã€ã®ããŒã¿ãã¬ãŒã ãååãæå®ããŠãžã§ã€ã³ãã '<nl>pd.merge(df, df2, on='åA') '<nl>pd.merge(df, df2, on='åA')
ãããè²ã§æ£ã°ã©ããæç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='tomato') plt.bar(ããŒã¿åx, ããŒã¿åy, color='tomato')
option: ã°ã©ãã®è²ããã£ãŒã«ã«å€æŽãã color = 'teal' color = 'teal'
æ°ããæµ®åå°æ°ç¹æ°ãåŒã x - y x - y
ãšã³ãã£ã¢ã³ã調ã¹ã ã€ãã©ãã«(ã€ãã£ã³) sys.byteorder
ç·ã°ã©ããåéæã®å®ç·ã§æç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='solid', alpha=0.5) plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='solid', alpha=0.5)
äž»æååæãçšããŠå€æ¬¡å
ããŒã¿ãæåå次å
ã«æ¬¡å
åæžãã N = 2.0<nl>sklearn.decomposition.PCA(n_components=N).fit_transform(å€æ¬¡å
ããŒã¿) N = 2<nl>sklearn.decomposition.PCA(n_components=N).fit_transform(å€æ¬¡å
ããŒã¿)
ãã¹ãã°ã©ã ãšåŸé
ããŒã¹ãã£ã³ã°ã䜿ã£ãŠã¯ã©ã¹åé¡ãè¡ã model = sklearn.ensemble.HistGradientBoostingClassifier() model = sklearn.ensemble.HistGradientBoostingClassifier()
æååã®æåã®äœåãªç©ºçœãåãé€ã æåå.lstrip() æåå.lstrip()
é»ã倧ããããŒã«ãŒãšããŠæ£åžå³ããããããã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='X', c='k') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='X', c='k')
èŠçŽ ã¯ã¿ãã«ã®èŠçŽ ã§ãªãã調ã¹ã èŠçŽ not in ã¿ãã« èŠçŽ not in ã¿ãã«
空ã®åŸé
ããŒã¹ãã£ã³ã°ååž°æšãäœã model = sklearn.ensemble.GradientBoostingRegressor() model = sklearn.ensemble.GradientBoostingRegressor()
æ·¡ããã³ã¯è²è²ã§æšªæ£ã°ã©ããæç»ãã plt.barh(ããŒã¿åx, ããŒã¿åy, color='lightpink') plt.barh(ããŒã¿åx, ããŒã¿åy, color='lightpink')
空ã®åŸé
ããŒã¹ãã£ã³ã°åé¡æšãäœæãã model = sklearn.ensemble.GradientBoostingClassifier() model = sklearn.ensemble.GradientBoostingClassifier()
ã·ãšãè²ãšããŠæ£åžå³ãæç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, color='sienna') plt.scatter(ããŒã¿åx, ããŒã¿åy, color='sienna')
ãã¹ãã°ã©ã ã®è²ãèµ€ã«å€æŽãã plt.hist(ããŒã¿å, color='red') plt.hist(ããŒã¿å, color='red')
æãç·ã°ã©ããã¹ããŒã«ãã«ãŒè²ãçšããŠæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='steelblue') plt.plot(ããŒã¿åx, ããŒã¿åy, color='steelblue')
æååã¯ã¿ã€ãã«ã±ãŒã¹ãã©ãã調ã¹ã æåå.istitle() æåå.istitle()
æå®ããåãçŸã®äœã§äžžããŠãæŽæ°åã«ãã df['åA'].round(-2).astype(int) df['åA'].round(-2).astype(int)
ãã«ãŒã³ã«ãã¹ãã°ã©ã ã®è²ãèšå®ãã plt.hist(ããŒã¿å, color='maroon') plt.hist(ããŒã¿å, color='maroon')
æ¥ä»ããŒã¿ãéææ¥ã aDate.weekday() == 4 aDate.weekday() == 4
âŒå°ã䜿ã£ãŠæ£åžå³ãæç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='v') plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='v')
ç·ã°ã©ãããµãŒã¢ã³è²ã§æç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='salmon') plt.plot(ããŒã¿åx, ããŒã¿åy, color='salmon')
å€æ°ã0ã«è¿ã¥ãå Žåã®æ¥µéå€ãæ±ãã sympy.limit(æ°åŒ, å€æ°, 0) sympy.limit(æ°åŒ, å€æ°, 0)
ã¿ãã«ã®æåŸ ã¿ãã«[-1] ã¿ãã«[-1]
deqã®startãendã®éšåèŠçŽ ãèŠã collections.deque(itertools.islice(deq, start, end)) collections.deque(itertools.islice(deq, start, end))
æãç·ã°ã©ãã«ããå°ã䜿ã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='x') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='x')
暪æ£ã°ã©ããããã³ã¯è²ãšããŠæç»ãã plt.barh(ããŒã¿åx, ããŒã¿åy, color='deeppink') plt.barh(ããŒã¿åx, ããŒã¿åy, color='deeppink')
ã«ãŠã³ã¿ãé«é »åºŠæ¹ãããªã¹ããšããŠåŸã aCounter.most_common() aCounter.most_common()
æãç·ã°ã©ããåéæã®ç Žç·ãšããŠæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dashed', alpha=0.5) plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dashed', alpha=0.5)
ãããã³ã°ã®é
ç®åãåæãã èŸæž.keys() èŸæž.keys()
æµ®åå°æ°ç¹æ°ä»¥äžã®æ倧ã®æŽæ° math.floor(x) math.floor(x)
äºæž¬å€ãšããŒã¿ã®é¢ãå
·åãæç»ãã sns.resid(x='åå', y='åå', data=df) sns.residplot(x='åå', y='åå', data=df)
ããŒãããè²ã§æãç·ã°ã©ããæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='peachpuff') plt.plot(ããŒã¿åx, ããŒã¿åy, color='peachpuff')
ããŒã¿ãã¬ãŒã ã®ããã«ã©ã ã®ã¿ã€ã ãŸãŒã³ãæ±äº¬ã«èšå®ãã df['åA'].tz_convert('Asia/Tokyo') df['åA'].tz_convert('Asia/Tokyo')
é»ãâœããŒã«ãŒã§æ£åžå³ããããããã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='v', c='k') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='v', c='k')
èŸæžã®å€ã®äžèŠ§ãåç
§ãã èŸæž.values() list(èŸæž.values())
0ããNæªæºãŸã§ã®ãã¯ãã« np.arange(N) np.arange(N)
ãªã¹ããšæ°åã«ã€ããŠã®æ£åžå³ã«èµ€ã倧ããããŒã«ãŒãæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='X', c='r') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='X', c='r')
èµ€ãäžäžè§ããŒã«ãŒãšããŠæ£åžå³ãæã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='v', c='r') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='v', c='r')
ãã¡ã€ã«ãæžã蟌ã¿çšã«ãªãŒãã³ãã] open(filepath, mode='w') 'w' = 'a'<nl>open(filepath, mode='w')
option: æ¿ãéã䜿çšãã color = 'darkblue' color = 'darkblue'
äºã€ã®ããŒã¿åã®æ®å·®ãæ£åžå³ãšããŠæã sns.residplot(x=ããŒã¿å, y=ããŒã¿å) sns.residplot(x=ããŒã¿å, y=ããŒã¿å)
ããŒã¿ãã¬ãŒã ã衚瀺ãããšããããããŒè¡ãå³å¯ãã«æå®ãã pd.set_option('colheader_justify', 'right') pd.set_option('colheader_justify', 'right')
èµ€ãäžç¹éç·ã§æãç·ã°ã©ãããããããã plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dashbot', color='r') plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dashbot', color='r')
æ£åžå³ããªãªãŒãè²ãçšããŠæç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, color='olive') plt.scatter(ããŒã¿åx, ããŒã¿åy, color='olive')
èŸæžã®é
ç®åã«å¯Ÿå¿ããå€ èŸæž[ããŒ] èŸæž.get(ããŒ, èŠã€ãããªãå Žåã®å€)
å°æ°ç¹æ°ã®æŽæ°éš math.modf(x)[0] math.modf(x)[1]
æãç·ã°ã©ãã®è²ããµãã«ãã©ãŠã³ã«æå®ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='saddlebrown') plt.plot(ããŒã¿åx, ããŒã¿åy, color='saddlebrown')
æãç·ã°ã©ããã©ãã³ããŒè²ãšããŠæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='lavender') plt.plot(ããŒã¿åx, ããŒã¿åy, color='lavender')
æãç·ã°ã©ãã®è²ããã«ãŒãã€ãªã¬ããã«å€æŽãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='blueviolet') plt.plot(ããŒã¿åx, ããŒã¿åy, color='blueviolet')
æå®ããåã®å€ã§éèšãååèšãæ±ãã df.groupby('åA').sum() df.groupby('åA').sum()
ããããã«éçŽæ¹åã®äžç¹éç·ãä»ãã plt.axvline(x=0, linestyle='dashbot') plt.axvline(x=0, linestyle='dashbot')
ã«ãŠã³ã¿ã®é
ç®äžèŠ§ã䜿ã aCounter.keys() aCounter.keys()
ãã¹ãã°ã©ã ãããŒãã«è²ãšããŠæç»ãã plt.hist(ããŒã¿å, color='purple') plt.hist(ããŒã¿å, color='purple')
æŽæ°åã®ãŒãåããããè¡åãäœã np.zeros(èŠçŽ æ°, dtype=np.int) np.zeros(èŠçŽ æ°, dtype=np.int)
é
åã®ãã¢ãœã³ã®ç©ç«çžé¢ä¿æ° scipy.stats.pearsonr(é
å, é
å2) scipy.stats.pearsonr(é
å, é
å2)
æŽæ°ã1ããããã¯2ããããã¯3ã«çãããã©ãã調ã¹ã æŽæ° == 1 or æŽæ° == 2 or æŽæ° == 3 æŽæ° == 1 or æŽæ° == 2 or æŽæ° == 3
è¡åã®å€ãæ±ãã aArray[è¡çªå·, åçªå·] aArray[è¡çªå·, åçªå·]
t-SNEã§æŽæ°æ¬¡å
ã«åæžãã sklearn.manifold.TSNE(n_components=äž).fit_transform(å€æ¬¡å
ããŒã¿) sklearn.manifold.TSNE(n_components=äž).fit_transform(å€æ¬¡å
ããŒã¿)
äºã€ã®è¡šããŒã¿ã暪æ¹åã«ããŒãžãã pd.merge(df, df2) pd.merge(df, df2)
æ£åžå³ããã¯ã€ãã¹ã¢ãŒã¯è²ãšããŠæç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, color='whitesmoke') plt.scatter(ããŒã¿åx, ããŒã¿åy, color='whitesmoke')
ãµãã€ã®æ¡ä»¶ãæãç«ã€ æ¡ä»¶ and æ¡ä»¶2 æ¡ä»¶ and æ¡ä»¶2
ã¹ã«ã€ãã«ãŒã«ãã¹ãã°ã©ã ã®è²ãæå®ãã plt.hist(ããŒã¿å, color='skyblue') plt.hist(ããŒã¿å, color='skyblue')
瞊æ£ã°ã©ãããã³ã¯è²ã§æç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='pink') plt.bar(ããŒã¿åx, ããŒã¿åy, color='pink')
æå®ããåã®æšæ¬åæ£ãæ±ãã df['åA'].var(ddof=0) df['åA'].var(ddof=0)
ã倧ãããã x = 0.33<nl>model = sklearn.metrics.mean_squared_error(ããŒã¿å) å€æ° += æŽæ°
æŽæ°ã2ã§å²ãåããªã æŽæ° % 2 == 0 æŽæ° % 2 == 1
æ£ã°ã©ããé»ç·è²ã§æç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='chartreuse') plt.bar(ããŒã¿åx, ããŒã¿åy, color='chartreuse')
ããŒã»ã³ãä»ãã®åãããããæç»ãã plt.pie(ããŒã¿å, startangle=90, autopct='%.2f%%') plt.pie(ããŒã¿å, startangle=90, autopct='%.2f%%')
ASCIIéå®ãšããŠæ£èŠè¡šçŸã§æååãåºåã re.split(pattern, s, flags=re.ASCII) re.split(pattern, s, flags=re.ASCI)
èµ€ãæããŒã«ãŒãšããŠæ£åžå³ãæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='*', c='r') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='*', c='r')
ããŒã¿ãã¬ãŒã ã®åã®ãŠããŒã¯ãªå€ã®åæ°ã確èªãã df[col].nunique() df[col].nunique()
æ£ã°ã©ãã玺è²ãšããŠæç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='darkblue') plt.bar(ããŒã¿åx, ããŒã¿åy, color='darkblue')
瞊æ£ã°ã©ããããŒã«ãã€ãªã¬ããã¬ããè²ãšããŠæç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='palevioletred') plt.bar(ããŒã¿åx, ããŒã¿åy, color='palevioletred')
åã®å€ã§ããŒã¿ã·ãªãŒãºã®æ¬ æå€ãåãã ds.fillna(method='ffill') ds.fillna(method='ffill')
é»ãäžäžè§ããŒã«ãŒãæ£åžå³ã«æç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='v', markerfacecolor='k') plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='v', markerfacecolor='k')
ã«ã©ã ã®ã¢ãŒããæ±ãã mode, count = scipy.stats.mode(df['åA']) mode, count = scipy.stats.mode(df['åA'])
ãªã¹ããšãªã¹ãã«ã€ããŠã®æ£åžå³ã«äžäžè§ããŒã«ãŒãæã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='v') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='v')
ããŒã¿åã®ãšããã¯ç§ãPandasã®æ¥ä»åã«å€æãã pd.to_datetime(ds, unit='s', utc=True) pd.to_datetime(ds, unit='s', utc=True)
ã«ãŠã³ã¿ã®æé »åºãªæåå aCounter.most_common()[0] aCounter.most_common()[0]
ç·ã°ã©ãã®è²ãã¢ã³ãã£ãŒã¯ãã¯ã€ãã«ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='antiquewhite') plt.plot(ããŒã¿åx, ããŒã¿åy, color='antiquewhite')
ç·ã°ã©ãã®è²ãã·ãŒã°ãªãŒã³ã«æå®ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='seagreen') plt.plot(ããŒã¿åx, ããŒã¿åy, color='seagreen')
åé¡æšãå¯èŠåãã plt.barh(X.columns, model.feature_importances_) sklearn.tree.plot_tree(model, feature_names=X.columns, filled=True)
æ°åãå
šãŠèŠã string.digits string.digits
ãã¢ãœã³ã§ããŒã¿ãã¬ãŒã ã®äžéšã®ã«ã©ã ã®çžé¢è¡åãæ±ãã df[['åA', 'åB']].corr(method='pearson') df[['åA', 'åB']].corr(method='pearson')
åãããããçåã«ãã plt.axis('equals') plt.axis('equals')
ã«ã©ã ã®æªã¿ãèšç®ãã df['åA'].kurt() scipy.stats.skew(df['åA'], bias=False)
æãç·ã°ã©ãã®ç·çš®ãå®ç·ã«ã»ãããã plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='solid') plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='solid')
ãã¡ã€ã«ãã¹ã®ãã©ã«ãåãæ±ãã os.path.dirname(filepath) os.path.dirname(filepath)
æ°åã®ãã¢ãœã³ã®ç©ç«çžé¢ä¿æ° scipy.stats.pearsonr(æ°å, æ°å2) scipy.stats.pearsonr(æ°å, æ°å2)
nåã«çééã§ãªã¹ããåå²ãã pd.cut(aList, n) pd.cut(aList, n)
ã¿ã³è²ã§æšªæ£ã°ã©ããæç»ãã plt.barh(ããŒã¿åx, ããŒã¿åy, color='tan') plt.barh(ããŒã¿åx, ããŒã¿åy, color='tan')
æååã¯ããŒã¯ãŒãã調ã¹ã æåå.iskeyword() keyword.iskeyword(æåå)
option: ã¢ã€ããªãŒã«ãã©ã³ãã®è²ãå€æŽãã color = 'ivory' color = 'ivory'
ããããã®æç»ã§æããã«ã©ãŒãã¬ãããçšãã sns.set(pallete='bright') sns.set(pallete='bright')
ãã«ãŒãã€ãªã¬ããè²ã§çžŠæ£ã°ã©ããæç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='blueviolet') plt.bar(ããŒã¿åx, ããŒã¿åy, color='blueviolet')
åéæã®äžç¹éç·ã§æãç·ã°ã©ããæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dashbot', alpha=0.5) plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dashbot', alpha=0.5)
ã°ã©ãã®æç»ã§æ·¡ãè²ãçšãã sns.set(pallete='muted') sns.set(pallete='muted')
暪æ£ã°ã©ããéç·è²ãšããŠæç»ãã plt.barh(ããŒã¿åx, ããŒã¿åy, color='teal') plt.barh(ããŒã¿åx, ããŒã¿åy, color='teal')
æååã§åºåã£ãŠxãšyãåºåãã print(x, y, sep='\t') print(x, y, sep=s)
ã»ããã®èŠçŽ æ°ãæ±ãã len(ã»ãã) len(ã»ãã)
ããŒã¿ãã¬ãŒã ã®ããã«ã©ã ã®æååãæªå
¥åå€ã«å€æãã df['åA'].replace(å€, np.nan) df['åA'].replace(å€, np.nan)
è¡šããŒã¿ã®ããã«ã©ã ãæ¥ä»ããŒã¿ã«å€æããã€ã³ããã¯ã¹ã«ãã df.index = pd.DatetimeIndex(pd.to_datetime(df['åA'])) df.index = pd.DatetimeIndex(pd.to_datetime(df['åA']))
æãç·ã°ã©ãã«å³äžè§ããŒã«ãŒã䜿çšãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='>') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='>')
ValueMapã§ããŒã¿ãã¬ãŒã ã®éžæããã«ã©ã ãå
šãŠçœ®æãã df[['åA', 'åB']].replace(ValueMap) df[['åA', 'åB']].replace(ValueMap)
ã¹ã¬ãŒããã«ãŒè²ã®æãç·ã°ã©ããæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='slateblue') plt.plot(ããŒã¿åx, ããŒã¿åy, color='slateblue')
ããŒã¿ãã¬ãŒã ãé¢æ°ã®å€ããšã«ã°ã«ãŒãåããŠãåæãã [(name, group_df) for name, group_df in df.groupby(é¢æ°)] [(name, group_df) for name, group_df in df.groupby(é¢æ°)]
ãªã¬ã³ãžã¬ããè²ã§æ£ã°ã©ããæç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='orangered') plt.bar(ããŒã¿åx, ããŒã¿åy, color='orangered')
option: ã©ã€ãã¹ã¬ã€ã°ã¬ãŒã«ã°ã©ãã®è²ãèšå®ãã color = 'lightslategrey' color = 'lightslategray'
ããŒã¯ã°ã¬ãŒè²ã®çžŠæ£ã°ã©ããæç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='darkgrey') plt.bar(ããŒã¿åx, ããŒã¿åy, color='darkgray')
äœç»ã«äœ¿ããã©ã³ããæå®ãã sns.set(font=ãã©ã³ãå) sns.set(font=ãã©ã³ãå)
ãã¡ã€ã«ãèªã¿èŸŒã¿ã¢ãŒãã§ãªãŒãã³ããŠ]fãšãã f = open(filepath, mode='r') f = open(filepath, mode='r')
ããŒã¿ãã¬ãŒã ã100ã®äœã§äžžãã df.round(-2) df.round(-2)
ããŒã¿åãšãªã¹ãã®æ£åžå³ãæç»ããŠå€§ããããŒã«ãŒã®è²ãrgbã«ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='X', c=rgb) plt.plot(ããŒã¿åx, ããŒã¿åy, marker='X', c=rgb)
æ°ãnä¹ãã x ** n x ** n
ç·ã°ã©ããéãç Žç·ã§æã plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dashed', color='b') plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dashed', color='b')
äœç»ã§äœ¿ãã«ã©ãŒãã¬ãããæå®ãã sns.set(pallete='ãã¬ããå') sns.set(pallete=ãã¬ããå)
ãã©ã è²ã§ãã¹ãã°ã©ã ãæç»ãã plt.hist(ããŒã¿å, color='plum') plt.hist(ããŒã¿å, color='plum')
ããŒã¿ãã¬ãŒã ã®æ£åžå³ãã°ã«ãŒãåããŠæšªã«é
眮ãã sns.relplot(data=df, x='åå', y='åå', hue='ã«ããŽãªå', row='ã«ããŽãªå', row='ã«ããŽãªå') sns.relplot(data=df, x='åå', y='åå', hue='ã«ããŽãªå', col='ã«ããŽãªå')
å€æ°ãå®çŸ©ããã å€æ° += æŽæ° X = 0
ããŒã¿ãã¬ãŒã ã®ã«ã©ã ã®ããªã åæ£ãèšç®ãã scipy.stats.tvar(df['åA'], limits=(äžé, äžé), inclusive=(True, True)) scipy.stats.tvar(df['åA'], limits=(äžé, äžé), inclusive=(True, True))
Xã®åä¹ãæ±ããã X ** 4 X ** 4
ã¯ã©ã¹åé¡ãã¬ãŠã¹éçšãšããŠè¡ã model = sklearn.gaussian_process.GaussianProcessClassifier() model = sklearn.gaussian_process.GaussianProcessClassifier()
å
šèŠçŽ ã0ã§åæåãããã¯ãã« np.zeros(èŠçŽ æ°) np.zeros(èŠçŽ æ°)
â²å°ãçšããæ£åžå³ãæç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='^') plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='^')
æååããœãŒãããŠJSONã«ãšã³ã³ãŒããã json.dumps(æåå, ensure_ascii=False, sort_keys=True) json.dumps(æåå, ensure_ascii=False, sort_keys=True)
ãªã¹ãã®å€ãå°ããé ã«äžŠã¹ã sorted(ãªã¹ã, reverse=True) sorted(ãªã¹ã, reverse=True)
æ°åããéè€ãªããã©ã³ãã ã«nèŠçŽ éžãã§ãªã¹ãã«ãã random.sample(æ°å, k=n) random.sample(æ°å, k=n)
ã€ãã©ãã«ãã©ã³ãã ã«ã·ã£ããã«ããŠãªã¹ãåãã random.sample(ã€ãã©ãã«, len(ã€ãã©ãã«)) random.sample(ã€ãã©ãã«, len(ã€ãã©ãã«))
é
ãã»ããã«å«ãŸããªãã確èªãã èŠçŽ not in ã»ãã èŠçŽ not in ã»ãã
æååãæ¹è¡ã§åå²ããæååãªã¹ãã«ãã æåå.splitlines() æåå.splitlines()
æ¬æ¥ã®ææ¥ãæŽæ°ã§æ±ãã datetime.datetime.today().astype(int) datetime.datetime.today().weekday()
æ·¡ãè¶è²è²ã§æ£åžå³ãæç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, color='tan') plt.scatter(ããŒã¿åx, ããŒã¿åy, color='tan')
option: ã¢ã€ããªãŒã«è²ãæå®ãã color = 'ivory' color = 'ivory'
option: ããžã£ãŒãã«ãŒã«ã°ã©ãã®è²ãå€æŽãã color = 'dodgerblue' color = 'dodgerblue'
æŽæ°ã-9以äž9以äžãå€å®ãã -9 <= æŽæ° <= 9 -9 <= æŽæ° <= 9
æ£ã°ã©ããããŒã«ã°ãªãŒã³è²ãçšããŠæç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='palegreen') plt.bar(ããŒã¿åx, ããŒã¿åy, color='palegreen')
ããŒã¿ãã¬ãŒã äžã®æ¬ æå€ãã€ã³ãã¬ã€ã¹ã§ãããããã df.dropna(inplace=True) df.dropna(inplace=True)
åé¡ã¢ãã«ã®åœãŠã¯ããå®è¡ãã model.fit(説æå€æ°, ç®çå€æ°) model.fit(説æå€æ°, ç®çå€æ°)
CSVãã¡ã€ã«ãã«ã©ã åãæå®ããèªã¿èŸŒã pd.read_csv('file.csv', header=None) pd.read_csv('file.csv', header=None)
ããŒã¿ã·ãªãŒãºã®ææ¥ã¯äœæ¥ç®ã調ã¹ã ds.dt.dayofweek ds.dt.dayofweek
ãã¹ãã°ã©ã ã®è²ãã©ã€ããµãŒã¢ã³ã«æå®ãã plt.hist(ããŒã¿å, color='lightsalmon') plt.hist(ããŒã¿å, color='lightsalmon')
æ£åžå³ãã¹ã«ã€ãã«ãŒè²ãšããŠæç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, color='skyblue') plt.scatter(ããŒã¿åx, ããŒã¿åy, color='skyblue')
床æ°ååžå³ãšããŠããŒã¿ãã¬ãŒã ã®ã«ã©ã ããããããã plt.hist(df[column]) plt.hist(df[column])
æååãæåŸã®ã«ã³ããçšããŠäºã€ã«åãã æåå.rpartition(',') æåå.rpartition(',')
æŽæ°ã®3ä¹ãç®åºãã æŽæ° ** 3 æŽæ° ** 3
æ£åžå³ã®å³äžè§ããŒã«ãŒã®ç·å¹
ãèšå®ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='>', markeredgewidth=2.5) plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='>', markeredgewidth=2.5)
ç·åœ¢ååž°ã¢ãã«ã®ååž°å€æ°ã䜿ã model.intercept_decomposition.PLSRegression() model.coef_
æãç·ã°ã©ãã®è²ãã²ã€ã³ãºããã«ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='gainsboro') plt.plot(ããŒã¿åx, ããŒã¿åy, color='gainsboro')
æŽæ°ã2ã§å²ãåããªãã æŽæ° % 2 == 1 æŽæ° % 2 == 1
ããã¹ããªç·åœ¢ã¯ã©ã¹åé¡ãè¡ã model = sklearn.linear_model.HuberClassifier() model = sklearn.linear_model.HuberClassifier()
ããåã®æååãéšåæååã§çµãããªãããŒã¿ãæœåºãã df[~ df['åA'].str.endswith(éšåæåå)] df[~ df['åA'].str.endswith(éšåæåå)]
ç·ã°ã©ããã©ã€ãã¹ã¬ã€ã°ã¬ãŒè²ã§æç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='lightslategrey') plt.plot(ããŒã¿åx, ããŒã¿åy, color='lightslategrey')
ã©ã€ã³ãèµ€ãäžç¹éç·ã§æç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dashbot', color='r') plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dashbot', color='r')
å²ããæžããã X // Y X / Y
option: ã°ã©ãã®è²ãããªãŒãŠããã«å€æŽãã color = 'burlywood' color = 'burlywood'
option: ç®±ã²ãå³ã暪æ¹åã«ãã linewidth = 3.0 vert = False
ããŒã¿ãã¬ãŒã ãã«ãã€ãªãªã³å³ã§èŠã sns.violinplot(x='ã«ããŽãªå', y='å', data=df) sns.violinplot(x='ã«ããŽãªå', y='å', data=df)
èµ€ã倧ããããŒã«ãŒãæãç·ã°ã©ãã«æç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='X', markerfacecolor='r') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='X', markerfacecolor='r')
ãã¹ãã°ã©ã ã®è²ãããŒã³ã°ãªãŒã³ã«å€æŽãã plt.hist(ããŒã¿å, color='lawngreen') plt.hist(ããŒã¿å, color='lawngreen')
æãç·ã°ã©ãã®è²ãã€ã³ãã£ã¢ã³ã¬ããã«æå®ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='indianred') plt.plot(ããŒã¿åx, ããŒã¿åy, color='indianred')
æååãã»ãã¬ãŒã¿ã§äºåããåŸåãèŠã æåå.partition(ã»ãã¬ãŒã¿)[-1] æåå.partition(ã»ãã¬ãŒã¿)[-1]
ãããœååž°ã¢ãã«ãæ°èŠäœæãã model.fit(説æå€æ°, ç®çå€æ°) model = sklearn.linear_model.Rosso(alpha=æ£ååé
)
æžåŒã§åãæ¥ä»ããŒã¿ã«å€æãã pd.to_datetime(df['åA'], format='%Y-%m-%d') pd.to_datetime(df['åA'], format='%Y-%m-%d')
ç®±ã²ãå³ã暪ã«äžŠã¹ãŠæã plt.boxplot([ããŒã¿å, ããŒã¿å]) plt.boxplot([ããŒã¿å, ããŒã¿å])
option: ã³ãŒã©ã«è²ãçšãã color = 'coral' color = 'coral'
ããŒã¿åã®æãç·ã°ã©ããå³äžè§å°ã䜿ã£ãŠæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='>') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='>')
æ¯åç°ãªãããã«ä¹±æ°ãåæåãã random.seed() random.seed()
option: ã©ã€ãã€ãšããŒã«ã°ã©ãã®è²ãèšå®ãã color = 'lightyellow' color = 'lightyellow'
ããŒã¿ãã¬ãŒã ã®NaNãåã®è¡ã®å€ã§è£å®ãã df.fillna(method='ffill') df.fillna(method='ffill')
option: å°éºŠè²ã䜿ã color = 'wheat' color = 'wheat'
ããããŒã«ãŒã§æ£åžå³ãæã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='x') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='x')
ãªããžã§ã¯ããååä»ãã¿ãã«åãã©ãã調ã¹ã hasattr(obj, '_asdict') and hasattr(obj, '_fields') hasattr(obj, '_asdict') and hasattr(obj, '_fields')
æµ®åå°æ°ç¹æ°ã®æå°å€ãç®åºãã sys.float_info.min sys.float_info.min
option: ãã©ã³ãã®è²ãã©ãã³ããŒã«ã»ãããã color = 'lavender' color = 'lavender'
æå®ããã«ã©ã ã®æ¬ æå€ãçŽåŸã®å€ã«æå®ãã df['åA'].fillna(method='bfill') df['åA'].fillna(method='bfill')
é
åãçéã§åå²æ°nã§ãã³ãã³ã°ãã pd.qcut(aArray, n) pd.qcut(aArray, n)
ãŽãŒã«ãã«ãã¹ãã°ã©ã ã®è²ãèšå®ãã plt.hist(ããŒã¿å, color='gold') plt.hist(ããŒã¿å, color='gold')
瞊æ£ã°ã©ãã®è²ãæ·¡ããã³ã¯è²ã«ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='lightpink') plt.bar(ããŒã¿åx, ããŒã¿åy, color='lightpink')
瞊æ£ã°ã©ãããã©ã¬ã¹ãã°ãªãŒã³è²ã§æç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='forestgreen') plt.bar(ããŒã¿åx, ããŒã¿åy, color='forestgreen')
éšåæååã§æååãäºåå²ããååã䜿ã æåå.partition(éšåæåå)[0] æåå.partition(éšåæåå)[0]
å¹³å絶察誀差ãæ±ãã sklearn.metrics.mean_absolute_denominator(alpha=0.5) sklearn.metrics.mean_absolute_error(ããŒã¿å, ããŒã¿å2)
ãŒãåããããè€çŽ æ°åã®ãã¯ãã«ãäœã np.zeros(èŠçŽ æ°, dtype=bool) np.zeros(èŠçŽ æ°, dtype=bool)
æååããã€ãåã«ãã bytes(s) bytes(s)
æãç·ã°ã©ãã®è²ããã¯ã·ã¢ã«ã»ãããã plt.plot(ããŒã¿åx, ããŒã¿åy, color='fuchsia') plt.plot(ããŒã¿åx, ããŒã¿åy, color='fuchsia')
option: ãã©ã³ãã®è²ããªãªããã©ãã«æå®ãã color = 'olivedrab' color = 'olivedrab'
ãã¹ãã°ã©ã ããã¹ãã£ããŒãºè²ãšããŠæç»ãã plt.hist(ããŒã¿å, color='mistyrose') plt.hist(ããŒã¿å, color='mistyrose')
暪æ£ã°ã©ããã©ãã³ããŒãã©ãã·ã¥è²ãçšããŠæç»ãã plt.barh(ããŒã¿åx, ããŒã¿åy, color='lavenderblush') plt.barh(ããŒã¿åx, ããŒã¿åy, color='lavenderblush')
æãç·ã°ã©ãã®âœå°ã®å€§ãããèšå®ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='v', markersize=2.0) plt.plot(ããŒã¿åx, ããŒã¿åy, marker='v', markersize=2.0)
ããŒããããã«ååšãã ã㌠not in èŸæž ã㌠not in èŸæž
ç·ã°ã©ãããã©ãŠã³è²ã§æç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='brown') plt.plot(ããŒã¿åx, ããŒã¿åy, color='brown')
æ¢åã®è¡åãããŒã¹ã«å
šèŠçŽ ã1ã®é
åãäœæãã np.ones_like(aArray) np.ones_like(aArray)
æååãåºåãèšå·ã§åå²ããŠãæååãªã¹ãã«ãã æåå.split(ã»ãã¬ãŒã¿) æåå.split(ã»ãã¬ãŒã¿)
ãã¡ã€ã«ãããã¡ã€ã«åãæ±ãã os.path.basename(filepath) os.path.basename(filepath)
ã³ãµã€ã³ãæ±ãã math.cosh(x) math.cos(x)
æ°åŒã®å€æ°ãããæ°åŒã§çœ®ãæãã æ°åŒ.subs(å€æ°, æ°åŒ2) æ°åŒ.subs(å€æ°, æ°åŒ2)
ç·ã°ã©ãã®è²ãã·ãšãã«èšå®ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='sienna') plt.plot(ããŒã¿åx, ããŒã¿åy, color='sienna')
æ£åžå³ããã€ã³ãå°ã§æç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='.') plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='.')
瞊æ£ã°ã©ãã®è²ããã£ã ã°ã¬ãŒã«ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='dimgrey') plt.bar(ããŒã¿åx, ããŒã¿åy, color='dimgrey')
ãã¹ã®ã»ãã¬ãŒã¿èšå·ãèŠã os.sep os.sep
ããŒã¿ãã¬ãŒã ã®æå®ããåã®æ¬ æå€ãçŽåã®å€ã§åãã df['åA'].fillna(method='ffill') df['åA'].fillna(method='ffill')
æŽæ°ã®ã¢ãžã¥ããèšç®ãã æŽæ° % æŽæ°2 æŽæ° % æŽæ°2
åäžèŠ§ df.info() df.info()
option: è²ãããŒãžãŒãã©ãŠã³ã«å€æŽãã color = 'rosybrown' color = 'rosybrown'
y座æšã察æ°ã«å€æŽãã plt.yscale('log') plt.yscale('log')
ãã¹ãã°ã©ã ãé»ç·è²ã§æç»ãã plt.hist(ããŒã¿å, color='chartreuse') plt.hist(ããŒã¿å, color='chartreuse')
䞡端ãã¥ãŒã®å
é ã«æ°åã®å€ãè¿œå ãã 䞡端ãã¥ãŒ.extendleft(æ°å) 䞡端ãã¥ãŒ.extendleft(æ°å)
æãç·ã°ã©ãã®ããŒã«ãŒãâœã«ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='v') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='v')
暪æ£ã°ã©ããã©ã€ãã¹ã¬ã€ã°ã¬ãŒè²ãçšããŠæç»ãã plt.barh(ããŒã¿åx, ããŒã¿åy, color='lightslategrey') plt.barh(ããŒã¿åx, ããŒã¿åy, color='lightslategrey')
xã®å°æ°ç¹ä»¥äž'1'æ¡ã®æååã«å€æãã ':.1f'.format(x) ':.1f'.format(x)
æååã空çœãçšããŠåå²ãã æåå.partition() æåå.split()
é
åã®åããšã®å¹³åå€ãç®åºãã np.mean(aArray, axis=0) np.mean(aArray, axis=0)
æžãåºãCSV圢åŒã®å°æ°ç¹ä»¥äžã®æ¡æ°ãèšå®ãã df.to_csv('file.csv', float_format='%.3f') df.to_csv('file.csv', float_format='%.3f')
åæ¹åãã¥ãŒã®å
é ã«ã€ãã©ãã«ã®åããŒã¿ãè¿œå ãã 䞡端ãã¥ãŒ.extendleft(ã€ãã©ãã«) 䞡端ãã¥ãŒ.extendleft(ã€ãã©ãã«)
倧æåãå°æåã«å€æãã æåå.lower() æåå.lower()
ããŒã¿ãã¬ãŒã ãé¢æ°ã®å€ã«ãã£ãŠéçŽããŠãåæãã [(name, group_df) for name, group_df in df.groupby(é¢æ°)] [(name, group_df) for name, group_df in df.groupby(é¢æ°)]
ã€ã³ãã³ãå¹
ãæå®ããŠããŒã¿ãJSONã«ãšã³ã³ãŒããã json.dumps(ããŒã¿, ensure_ascii=False, indent=n) json.dumps(ããŒã¿, ensure_ascii=False, indent=n)
ããŒã¿ãã¬ãŒã ã®æåŸ10è¡ãæœåºãã df.tail(10) df.tail(10)
ã²ãšã€ã§ãéã¢ã¹ããŒæåãæååäžã«ããã調ã¹ã any(not c.isascii() for c in æåå) any(not c.isascii() for c in æåå)
ã»ãããå€æŽäžèœãªéåã«ãã frozenset(ã»ãã) frozenset(ã»ãã)
æ£ã°ã©ããããŒãããè²ã䜿ã£ãŠæç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='peachpuff') plt.bar(ããŒã¿åx, ããŒã¿åy, color='peachpuff')
é
åã®ãŠããŒã¯ãªèŠçŽ ãšãã®äœçœ®ã調ã¹ã u, indices = np.unique(aArray, return_index=True) u, indices = np.unique(aArray, return_index=True)
æ£åžå³ããã³ã¯è²ãšããŠæç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, color='pink') plt.scatter(ããŒã¿åx, ããŒã¿åy, color='pink')
æ倧é·ãæå®ããŠãã¹ã¿ã㯠䞡端ãã¥ãŒ.extend(maxlen=æ倧é·) collections.deque(maxlen=æ倧é·)
ãããŒãã¥ãŒè²ãšããŠæ£åžå³ãæç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, color='honeydew') plt.scatter(ããŒã¿åx, ããŒã¿åy, color='honeydew')
ç·ã°ã©ããã©ãã³ããŒè²ã§æç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='lavender') plt.plot(ããŒã¿åx, ããŒã¿åy, color='lavender')
option: ããŒã«ãŒã®è²ãéç·ã«ãã markerfacecolor = 'teal' markerfacecolor = 'turquoise'
äºã€ã®æååã¯ã±ãŒã¹ãç¡èŠããŠåãã æåå.casefold() == æåå2.casefold() æåå.casefold() == æåå2.casefold()
ããŒã¿ãã¬ãŒã ã®æå®ããåã®ç©ºæåãæ¬ æå€ã«å€æãããããããã df['åA'].replace('', np.nan).dropna() df['åA'].replace('', np.nan).dropna()
option: åè§ããŒã«ãŒã䜿çšãã marker ='s' marker = 's'
æ£åžå³ã«å³äžè§ããŒã«ãŒãçšãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='>') plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='>')
é»ãäžè§å°ãæãç·ã°ã©ãã«æç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='^', markerfacecolor='k') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='^', markerfacecolor='k')
ããŒã¿ãã¬ãŒã ã®æå®ããåã®æšæºåå·®ãªã© df['åA'].describe() df['åA'].describe()
ã«ã©ãŒãã¬ãããè²å·®å¥ãªããã sns.set(pallete='colorblind') sns.set(pallete='colorblind')
ã€ãã©ãã«ãšã€ãã©ãã«ã«ã€ããŠã®æ£åžå³ã«rgbã®äžžããŒã«ãŒãæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='o', c=rgb) plt.plot(ããŒã¿åx, ããŒã¿åy, marker='o', c=rgb)
æ£åžå³ã«äžäžè§ããŒã«ãŒãçšãã plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='v') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='v')
é
åãšæ°åã«ã€ããŠæ£åžå³ãæç»ãããæååãšããè£è¶³çšã®ã©ãã«ãã€ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, label=s) plt.scatter(ããŒã¿åx, ããŒã¿åy, label=s)
æååãæåã³ãŒãåã«ãã [ord(ch) for ch in æåå] [ord(ch) for ch in æåå]
option: ãµãã«ãã©ãŠã³ã«ã°ã©ãã®è²ãèšå®ãã color ='saddlebrown' color = 'saddlebrown'
ãŒãåããããïŒäºãããæŽæ°åã®é
åãåæåãã np.zeros(èŠçŽ æ°, dtype=np.int16) np.zeros(èŠçŽ æ°, dtype=np.int16)
ç·åœ¢ååž°ã¢ãã«ãäœã model.fit(説æå€æ°, ç®çå€æ°) model = sklearn.linear_model.LinearRegression()
æå®ããåã®ã«ããŽãªã§éèšãæå°å€ãæ±ãã df.groupby('åA').min() df.groupby('åA').min()
暪æ£ãããããæç»ããŠãã©ãã«ãäžå¯ããã plt.barh(ã©ãã«å, ããŒã¿å, align='edge') plt.barh(ã©ãã«å, ããŒã¿å, align='edge')
æ£åžå³ã«èµ€ãäžäžè§ããŒã«ãŒã䜿çšãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='v', c='r') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='v', c='r')
æ¿ãã·ã¢ã³ã«ãã¹ãã°ã©ã ã®è²ãå€æŽãã plt.hist(ããŒã¿å, color='darkcyan') plt.hist(ããŒã¿å, color='darkcyan')
瞊æ£ã°ã©ããããŒã¯ãªãŒãããè²ãšããŠæç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='darkorchid') plt.bar(ããŒã¿åx, ããŒã¿åy, color='darkorchid')
æå®ããã«ã©ã ã®äžã«æååãšæååãååšãã df['åA'].isin([value, value2]) df['åA'].isin([value, value2])
ãªã¹ããšé
åã®æ£åžå³ã«é»ãå³äžè§ããŒã«ãŒãæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='>', c='k') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='>', c='k')
ã°ã©ãã§å©çšå¯èœãªè²åã®äžèŠ§ãç¥ã matplotlib.colors.cnames matplotlib.colors.cnames
æãç·ã°ã©ããæãèµ€è²ãšããŠæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='darkred') plt.plot(ããŒã¿åx, ããŒã¿åy, color='darkred')
option: ãã©ã¬ã¹ãã°ãªãŒã³ãçšãã color = 'forestgreen' color = 'forestgreen'
é
åãšã€ãã©ãã«ã®æ£åžå³ãæç»ããŠãããŒã«ãŒãå·Šäžè§ã«èšå®ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='<') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='<')
ãã¹ãã°ã©ã ãã¹ã©ã°ã¬ãŒè²ãçšããŠæç»ãã plt.hist(ããŒã¿å, color='slategray') plt.hist(ããŒã¿å, color='slategrey')
æ£åžå³ã«èµ€ãâœããŒã«ãŒãæç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='v', markerfacecolor='r') plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='v', markerfacecolor='r')
æååããéšåæååãåãé€ã æåå.replace(éšåæåå, '') æåå.replace(éšåæåå, '')
ãã¹ãã°ã©ã ãæç»ããŠãåéæåã«ãã plt.hist(ããŒã¿åx, alpha=0.5) plt.hist(ããŒã¿åx, alpha=0.5)
å
¥åããïŒã€ã®æååãèªã¿èŸŒã A, B = map(str, input().split()) A, B = map(str, input().split())
rgbã®ãã€ã³ãããŒã«ãŒãæ£åžå³ã«çšãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='.', c=rgb) plt.plot(ããŒã¿åx, ããŒã¿åy, marker='.', c=rgb)
option: ãã©ã³ãã®è²ããã¬ãããã«ã³ã€ãºã«æå®ãã color = 'paleturquoise' color = 'paleturquoise'
ããŒã¿ãã¬ãŒã ãValueMapã§ãŸãšããŠçœ®ãæãã df.replace(ValueMap) df.replace(ValueMap)
æŽæ°ãã»ããã®ããã æ° in ã»ãã æ° in ã»ãã
æ£åžå³ã®å³äžè§å°ã®è²ãå€ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='>', markerfacecolor='#800080') plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='>', markerfacecolor='#800080')
æãç·ã°ã©ãã«èµ€ãâ³ããŒã«ãŒãæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='^', markerfacecolor='r') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='^', markerfacecolor='r')
暪æ£ã°ã©ããããŒã¯ã¬ããè²ã§æç»ãã plt.barh(ããŒã¿åx, ããŒã¿åy, color='darkred') plt.barh(ããŒã¿åx, ããŒã¿åy, color='darkred')
æãç·ã°ã©ãããµãã«ãã©ãŠã³è²ãšããŠæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='saddlebrown') plt.plot(ããŒã¿åx, ããŒã¿åy, color='saddlebrown')
å
šè¬çã«è²ãæ·¡ããã sns.set(pallete='muted') sns.set(pallete='muted')
ã·ãŒã±ã³ã¹ãè¡åã«å€æãã np.array(iterable) np.array(iterable)
暪æ£ã°ã©ããã²ã€ã³ãºããè²ãšããŠæç»ãã plt.barh(ããŒã¿åx, ããŒã¿åy, color='gainsboro') plt.barh(ããŒã¿åx, ããŒã¿åy, color='gainsboro')
ãªã¹ãã®æåŸ ãªã¹ã[-1] ãªã¹ã[-1]
èŠãããã°ã©ããæç»ããæºåããã import seaborn as sns import seaborn as sns
æ°å€ãã»ããã«å«ãŸããã確èªãã æ° in ã»ãã æ° in ã»ãã
ããŒã¿ãã¬ãŒã ã®ã«ã©ã ã®æ¬ æå€ãå¹³åã«æå®ãã df['åA'].fillna(df['åA'].mean()) df['åA'].fillna(df['åA'].mean())
é
åãšãªã¹ãã«ã€ããŠã®æ£åžå³ã«é»ãäžäžè§ããŒã«ãŒãæã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='^', c='k') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='^', c='k')
ã©ã€ã ã°ãªãŒã³è²ãšããŠæ£åžå³ãæç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, color='limegreen') plt.scatter(ããŒã¿åx, ããŒã¿åy, color='limegreen')
ç·ã°ã©ããã¬ã¢ã³ã·ãã©ã³è²ã䜿ã£ãŠæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='lemonchiffon') plt.plot(ããŒã¿åx, ããŒã¿åy, color='lemonchiffon')
ãªã¹ããšãªã¹ãã«ã€ããŠæ£åžå³ãæç»ããŠãããŒã«ãŒã倧ããã«ã»ãããã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='X') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='X')
瞊æ£ã°ã©ããããããã³ã¯è²ã§æç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='hotpink') plt.bar(ããŒã¿åx, ããŒã¿åy, color='hotpink')
æååã®å³åŽããç¯å²ãæå®ããŠéšåæååãæ¢ã æåå.find(éšåæåå, éå§äœçœ®, çµäºäœçœ®) # èŠã€ãããªãå Žåã¯-1 æåå.find(éšåæåå, éå§äœçœ®, çµäºäœçœ®) # èŠã€ãããªãå Žåã¯-1
ããŒã¿ãã¬ãŒã ã®äžéšã®ã«ã©ã ã«ãããŠã©ã®å€ãæãåºçŸãããèŠã df[['åA', 'åB']].mode() df[['åA', 'åB']].mode()
ããŒã¿ãã¬ãŒã ã®è¡ãæ¡ä»¶ã§æ¶ã df[df.columns + å€) & (df['åA'] == x] df[(df['åA'] == x) & (df['åB'] == y)]
ããã«ã©ã ã®æååãéšåæååã§å§ãŸããªãè¡ãæœåºãã df[~ df['åA'].str.startswith(éšåæåå)] df[~ df['åA'].str.startswith(éšåæåå)]
äºã€ã®éåã®å·®éåãæ±ãã ã»ãã.difference(ã»ãã2) ã»ãã.difference(ã»ãã2)
ã»ãããè€è£œãã ã»ãã.copy() ã»ãã.copy()
æååã®äžã§ASCIIéå®ãšããŠãã¿ãŒã³ã«ãããããå
šæååããªã¹ãã«å€æãã re.findall(pattern, s, flags=re.ASCI) re.findall(pattern, s, flags=re.ASCI)
暪æ£ã°ã©ããããŒã¯ãµãŒã¢ã³è²ãšããŠæç»ãã plt.barh(ããŒã¿åx, ããŒã¿åy, color='darksalmon') plt.barh(ããŒã¿åx, ããŒã¿åy, color='darksalmon')
ããŒã¯ã«ãŒãã«ãã¹ãã°ã©ã ã®è²ãæå®ãã plt.hist(ããŒã¿å, color='darkkhaki') plt.hist(ããŒã¿å, color='darkkhaki')
ããŒã¿ãã¬ãŒã äžã®NaNããããããã df.dropna(inplace=True) df.dropna(inplace=True)
ããŒã¿åãéŸå€ã§ãã€ããªåãã sklearn.preprocessing.Binarizer(threshold=éŸå€).fit_transform(ããŒã¿å) sklearn.preprocessing.Binarizer(threshold=éŸå€).fit_transform(ããŒã¿å)
æ¡ä»¶ã«å¿ããŠãåäœãå€ããã if æ¡ä»¶åŒ:<nl><tab>print('çã®ãšã') # çŽããŠ<nl>else:<nl><tab>print('ããã§ãªããã°') # çŽã㊠if æ¡ä»¶åŒ:<nl><tab>print('çã®ãšã') # çŽããŠ<nl>else:<nl><tab>print('ããã§ãªããã°') # çŽããŠ
né²æååããã€ãåã«å€æãã int(æåå, n).to_bytes(length=ãã€ãæ°, byteorder='big') int(æåå, n).to_bytes(length=ãã€ãæ°, byteorder='big')
èŸæžã欲ãã èŸæž = {} èŸæž = {}
option: ã°ã©ãã®è²ãã¿ãŒã³ã€ãºã«å€æŽãã color = 'turquoise' color = 'turquoise'
ããã£ã¢ã ãã€ãªã¬ããã¬ããã«ãã¹ãã°ã©ã ã®è²ãèšå®ãã plt.hist(ããŒã¿å, color='mediumvioletred') plt.hist(ããŒã¿å, color='mediumvioletred')
ããç®ã®å°æ°ç¹ä»¥äžãåãäžããã (X + Y - 1) // Y (X + Y - 1) // Y
æ°åã®ã±ã³ããŒã«ã®çžé¢ä¿æ° scipy.stats.kendalltau(æ°å, æ°å2) scipy.stats.kendalltau(æ°å, æ°å2)
xãçœè²ã§è¡šç€ºã§ããæååã«ãã f'\033[37m{x}\033[0m' f'\033[37m{x}\033[0m'
æãç·ã°ã©ãã®äžžããŒã«ãŒã®å€ªããå€æŽãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='o', markeredgewidth=2.5) plt.plot(ããŒã¿åx, ããŒã¿åy, marker='o', markeredgewidth=2.5)
暪æ£ã°ã©ããé»è²è²ãšããŠæç»ãã plt.barh(ããŒã¿åx, ããŒã¿åy, color='yellow') plt.barh(ããŒã¿åx, ããŒã¿åy, color='yellow')
é
åããããŒå€æ°ã«ãã pd.get_dummies(é
å) pd.get_dummies(é
å)
æååãç¡éã«ç¹°ãè¿ãã€ãã©ãã«ã䜿ã itertools.repeat(element) itertools.repeat(æåå)
ç·ã°ã©ããåéæã®ç Žç·ãçšããŠæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dashed', alpha=0.5) plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dashed', alpha=0.5)
ããŒã¿ãã¬ãŒã ã®éžæããã«ã©ã ã®äžååæ£ãæ±ãã df[['åA', 'åB']].var(ddof=1) df[['åA', 'åB']].var(ddof=1)
é
åãšæ°åã«ã€ããŠã®æ£åžå³ã«èµ€ã倧ããããŒã«ãŒãæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='X', c='r') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='X', c='r')
暪軞ã®ç®çããé衚瀺ã«ãã plt.xticks([]) plt.xticks([])
ç·ã°ã©ãã®è²ãèç«ã¬ã³ã¬ã«ã»ãããã plt.plot(ããŒã¿åx, ããŒã¿åy, color='firebrick') plt.plot(ããŒã¿åx, ããŒã¿åy, color='firebrick')
æ£åžå³ã«èµ€ãå·Šäžè§ããŒã«ãŒã䜿çšãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='<', c='r') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='<', c='r')
æå®ãããåã®ã«ããŽãªã§éèšããæå°å€ãæ±ãã df.groupby('åA').min() df.groupby('åA').min()
ã€ã³ãã£ãŽè²ãšããŠæãç·ã°ã©ããæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='indigo') plt.plot(ããŒã¿åx, ããŒã¿åy, color='indigo')
æå®ããåã®å€ã¯NaNã df['åA'].isna() df['åA'].isna()
ãªã¹ãã®æšç§»ãè²ä»ãã®ç¹ç·ãšããŠæã plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dotted', color='#800080') plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dotted', color='#800080')
ãªããžã§ã¯ããéåæãžã§ãã¬ãŒã¿é¢æ°ã inspect.isasyncgenfunction(ãªããžã§ã¯ã) inspect.isasyncgenfunction(ãªããžã§ã¯ã)
èŸæžã«ããŒãååšããã確èªãã ã㌠in èŸæž ã㌠in èŸæž
ããŒã¿ãã¬ãŒã ã®äžã«æååããã df.isin([value]) df.isin([value])
ççè²ãçšããŠæ£ã°ã©ããæç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='coral') plt.bar(ããŒã¿åx, ããŒã¿åy, color='coral')
ãšã©ãŒãªããªã¹ãã®èŠçŽ ã®äœçœ®ãèŠã ãªã¹ã.index(èŠçŽ ) ãªã¹ã.index(èŠçŽ ) if èŠçŽ in ãªã¹ã else -1
ãã¡ã€ã«ãã¹ããã¹ããªãŒã ãèªã¿èŸŒãã§ãfileãšãã file = open(filepath) file = open(filepath)
æ£åžå³ã®â²å°ãéããã plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='^', markerfacecolor='b') plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='^', markerfacecolor='b')
æ¥ä»ããŒã¿ãæšææ¥ã aDate.weekday() == 3 aDate.weekday() == 3
æ¥ä»æå»ããŒã¿ãšæ¥ä»æå»ããŒã¿ã®æéå·®ãç§æ°ã§èšç®ãã (aDatetime - aDatetime2).total_seconds() (aDatetime - aDatetime2).total_seconds()//60
éè€ããè¡ã®ã¿ãæœåºãã df[df.duplicated(keep=False)] df[df.duplicated(keep=False)]
éãæããŒã«ãŒãæãç·ã°ã©ãã«æç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='*', markerfacecolor='b') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='*', markerfacecolor='b')
ããŒã¿ãã¬ãŒã ãäºã€ã®ã«ã©ã ã§å°ããé ã«ãœãŒããã df.sort_values(by=['åA', 'åB'], ascending=True) df.sort_values(by=['åA', 'åB'], ascending=True)
è¡åã®æšæºåå·®ãèšç®ãã np.std(aArray) np.std(aArray)
æŽæ°ã8é²æååã«å€æãã oct(æŽæ°)[2:] oct(æŽæ°)[2:]
ããŒã«ãã€ãªã¬ããã¬ããã«ãã¹ãã°ã©ã ã®è²ãæå®ãã plt.hist(ããŒã¿å, color='palevioletred') plt.hist(ããŒã¿å, color='palevioletred')
ãªããžã§ã¯ããã¯ã©ã¹ inspect.isclass(ãªããžã§ã¯ã) isinstance(obj, ã¯ã©ã¹)
倪åã§xãåºåãã print(f'\033[1m{x}\033[0m') print(f'\033[1m{x}\033[0m')
æ£åžå³ãã°ãªãŒã³ã€ãšããŒè²ã䜿ã£ãŠæç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, color='greenyellow') plt.scatter(ããŒã¿åx, ããŒã¿åy, color='greenyellow')
ãããŒã©ã«ãã¯ã€ãè²ãšããŠæãç·ã°ã©ããæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='floralwhite') plt.plot(ããŒã¿åx, ããŒã¿åy, color='floralwhite')
æãèµ€è²ãçšããŠæ£ã°ã©ããæç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='darkred') plt.bar(ããŒã¿åx, ããŒã¿åy, color='darkred')
ãªãã³è²ã§æ£ã°ã©ããæç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='linen') plt.bar(ããŒã¿åx, ããŒã¿åy, color='linen')
ããŒã¿ãã¬ãŒã ã®ããã«ã©ã ã®å°åºŠãç®åºãã df['åA'].skew() df['åA'].skew()
æ°åã®æšç§»ãåéæã®ç¹ç·ã§ãããããã plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dotted', alpha=0.5) plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dotted', alpha=0.5)
ãã¥ãŒã©ã«ããããšããŠã¯ã©ã¹åé¡ãè¡ã model = sklearn.linear_model.Normalizer(alpha=æ£ååé
) model = sklearn.neural_network.MLPClassifier(hidden_layer_sizes=(10, 10))
æ¥ä»ããŒã¿ã¯æ¥ä»ããŒã¿ããåŸãã調ã¹ã aDate > aDate2 aDate > aDate2
è²å·®å¥ãªãã«ã©ãŒãã¬ãããã°ã©ãã®æç»ã§äœ¿ã sns.set(pallete='colorblind') sns.set(pallete='colorblind')
ããã°ã©ã ãæ£ããçµäºãã sys.exit(0) sys.exit(0)
æ£åžå³ã®ãã€ã³ãå°ãéããã plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='.', markerfacecolor='b') plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='.', markerfacecolor='b')
ãã¹ãã°ã©ã ã®è²ããã¹ãã£ããŒãºã«æå®ãã plt.hist(ããŒã¿å, color='mistyrose') plt.hist(ããŒã¿å, color='mistyrose')
ããŒã¿ãã¬ãŒã ã®æ«å°Ÿnè¡ãéžæãã df.tail(n) df.tail(n)
æãç·ã°ã©ãã®è²ããã©ãã¯ã«æå®ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='black') plt.plot(ããŒã¿åx, ããŒã¿åy, color='black')
ã€ãã©ãã«ãšãªã¹ãã«ã€ããŠæ£åžå³ãæç»ããŠãã®å€§ãããnã«æå®ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, s=n) plt.scatter(ããŒã¿åx, ããŒã¿åy, s=n)
é
åã®è¡ããšã®åèšå€ãæ±ãã np.sum(aArray, axis=1) np.sum(aArray, axis=1)
éãå·Šäžè§ããŒã«ãŒãæãç·ã°ã©ãã«æç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='<', markerfacecolor='b') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='<', markerfacecolor='b')
æµ®åå°æ°ç¹æ°ãäžä¹ãã x ** 3 x ** 3
ïŒã€ã®é
åãç®±é«å³ã«ãã plt.boxplot([ããŒã¿å, ããŒã¿å]) plt.boxplot([ããŒã¿å, ããŒã¿å])
ã¢ã«ãã¡ããããèŠã string.ascii_letters string.ascii_letters
ã©ã€ãã€ãšããŒè²ã§ãã¹ãã°ã©ã ãæç»ãã plt.hist(ããŒã¿å, color='lightyellow') plt.hist(ããŒã¿å, color='lightyellow')
ã¿ãã«ã®èŠçŽ ãé¢æ°ã«é©çšããçµæã§ãœãŒããã sorted(ã¿ãã«, key=func) sorted(ã¿ãã«, key=func)
ã°ã©ãã«æ°Žå¹³æ¹åã®å®ç·ãã€ãã plt.axhline(y=0, linestyle='solid') plt.axhline(y=0, linestyle='solid')
TSVãã¡ã€ã«ãã¡ã€ã«åãã確èªãã filename = 'file.txt' # ãã¡ã€ã« name<nl>'.tsv' = '.csv'<nl>filename.startswith('.tsv') filename = 'file.txt' # ãã¡ã€ã« name<nl>'.tsv' = '.csv'<nl>filename.startswith('.tsv')
ISOæžåŒã®æååãæ¥ä»æå»ã«ãã datetime.datetime.fromisoformat(æ¥ä»ã®æžãããæåå) datetime.datetime.fromisoformat(æ¥ä»ã®æžãããæåå)
æ£åžå³ã«äžäžè§ããŒã«ãŒã䜿çšãã plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='v') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='v')
ãªã¹ããšé
åã«ã€ããŠã®æ£åžå³ã«èµ€ãäžäžè§ããŒã«ãŒãæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='v', c='r') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='v', c='r')
è€æ°ã®ãªã¹ããç®±é«å³ã«ãã plt.boxplot([ããŒã¿å, ããŒã¿å]) plt.boxplot([ããŒã¿å, ããŒã¿å])
ã¿ãã«ã®ç·å sum(ã¿ãã«) sum(ã¿ãã«)
ã°ã©ãã®æç»ã§ãã¹ãã«èª¿ã«ããŒãã䜿ã sns.set(pallete='pastel') sns.set(pallete='pastel')
è¡šãäºã€ã®åã«ãã£ãŠãŸãšããã°ã«ãŒããæ±ãã df.groupby(['åA', 'åB']) df.groupby(['åA', 'åB'])
èŸæžã®å
éšãè€è£œãã èŸæž.copy() {k: copy.copy(v) for k, v in èŸæž.items()}
option: ãã³ã¯ã«ã°ã©ãã®è²ãèšå®ãã color = 'pink' color = 'pink'
ã©ã€ã ã°ãªãŒã³è²ã§æ£ã°ã©ããæç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='limegreen') plt.bar(ããŒã¿åx, ããŒã¿åy, color='limegreen')
è±åãå
šéšäœ¿ã string.ascii_letters string.ascii_letters
ïŒã€ã®å€æ°ã®å€§ããæ¹ã欲ãã max(X, Y) max(X, Y)
ããŒã¯ã°ãªãŒã³è²ã§æ£ã°ã©ããæç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='darkgreen') plt.bar(ããŒã¿åx, ããŒã¿åy, color='darkgreen')
æãç·ã°ã©ããšããŠããŒã¿åã®æšç§»ãäœå³ãã plt.plot(range(len(ããŒã¿å)), ããŒã¿å) plt.plot(range(len(ããŒã¿å)), ããŒã¿å)
äžç¹éç·ã°ã©ããæã plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dashbot') plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dashbot')
床æ°ååžå³ãæç»ããŠããã³ãèšå®ãã plt.hist(ããŒã¿å, bins=åºé¢æ°) plt.hist(ããŒã¿å, bins=åºé¢æ°)
JSONãã¡ã€ã«ãã¡ã€ã«åã filename = 'file.txt'.date('.json') filename = 'file.txt' # ãã¡ã€ã« name<nl>'.json' = '.csv'<nl>filename.startswith('.json')
ããŒã¿ã·ãªãŒãºã®äžã«ããã®åèšãã«ãŠã³ããã ds.isin([value]).sum() ds.isin([value]).sum()
æ¥ä»æå»ããŒã¿ãæµ®åå°æ°ç¹æ°ã«ãã aDatetime.timestamp() aDatetime.timestamp()
èµ€ãâ²ããŒã«ãŒã§æ£åžå³ãæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='^', c='r') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='^', c='r')
æ¥ä»ããŒã¿ãåææ¥ã確èªãã aDate.weekday() == 5 aDate.weekday() == 5
ç·ã°ã©ããããã£ã¢ã ã¹ããªã³ã°ã°ãªãŒã³è²ã§æç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='mediumspringgreen') plt.plot(ããŒã¿åx, ããŒã¿åy, color='mediumspringgreen')
ããŒã¿ãã¬ãŒã ãæå®ãããã«ã©ã ã®å€ã«ãã£ãŠã°ã«ãŒãåãèšè¿°çµ±èšéãèšç®ãã df.groupby('åA').describe() df.groupby('åA').describe()
ã°ãªãŒã³è²ã§çžŠæ£ã°ã©ããæç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='green') plt.bar(ããŒã¿åx, ããŒã¿åy, color='green')
ããã¯ã®èŠçŽ æ° len(䞡端ãã¥ãŒ) len(䞡端ãã¥ãŒ)
è€æ°ã®æ¡ä»¶ãåæã«æãç«ã€ æ¡ä»¶ and æ¡ä»¶2 and æ¡ä»¶3 æ¡ä»¶ and æ¡ä»¶2 and æ¡ä»¶3
é»ãâŒããŒã«ãŒãšããŠæ£åžå³ãæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='v', c='k') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='v', c='k')
ããŒã¿ãã¬ãŒã ã®éžæããã«ã©ã ã®å€ãæ¬ æå€ãå€å®ãã df[['åA', 'åB']].isna() df[['åA', 'åB']].isna()
ããŒã¿ã·ãªãŒãºã®ã¿ã€ã ãŸãŒã³ãæå®ãã ds.tz_convert('Asia/Tokyo') ds.tz_convert('Asia/Tokyo')
èŸæžã®ãšã³ããªæ°ãåŸã len(èŸæž) len(èŸæž)
ããŒã¿ãã¬ãŒã ã®éžæããã«ã©ã ã®å¹³å df[['åA', 'åB']].mean() df[['åA', 'åB']].mean()
ãã¹ãã°ã©ã ã®è²ãã·ã«ããŒã«æå®ãã plt.hist(ããŒã¿å, color='silver') plt.hist(ããŒã¿å, color='silver')
暪æ£ã°ã©ããã¯ãªã ãŸã³è²ãšããŠæç»ãã plt.barh(ããŒã¿åx, ããŒã¿åy, color='crimson') plt.barh(ããŒã¿åx, ããŒã¿åy, color='crimson')
ããŒã¿ãã¬ãŒã ãã°ã«ãŒãåããããããã®åèšãç®åºãã df.groupby('åA').sum() df.groupby('åA').sum()
空çœã䜿ã import numpy as np ' '
å€æ°åãããŒãšããŠèŸæž dict(name='kogi', age=6) dict(name='kogi', age=6)
æ£ã°ã©ããã¹ã©ã°ã¬ãŒè²ãçšããŠæç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='slategray') plt.bar(ããŒã¿åx, ããŒã¿åy, color='slategray')
瞊æ£ã°ã©ããã·ã«ããŒè²ãšããŠæç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='silver') plt.bar(ããŒã¿åx, ããŒã¿åy, color='silver')
ããåã®ã«ããŽãªã§éèšããããããã®æšæºåå·®ãèšç®ãã df.groupby('åA').std() df.groupby('åA').std()
æ¥ä»æå»ããŒã¿ããnæéåæžç®ãã aDatetime - datetime.timedelta(hours=n) aDatetime - datetime.timedelta(hours=n)
èå¥åã¯æœè±¡ã¯ã©ã¹ãã©ãã調ã¹ã inspect.isabstract(èå¥å) inspect.isabstract(èå¥å)
æ£åžå³ã®äžäžè§å°ã®è²ãèšå®ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='v', markerfacecolor='#800080') plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='v', markerfacecolor='#800080')
é
åããåæ¹åãã¥ãŒãçšæãã collections.deque(é
å) collections.deque(é
å)
æãç·ã°ã©ããèµ€ãäžç¹éç·ã§æã plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dashbot', color='r') plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dashbot', color='r')
å®æ°ããæŽæ°ãæžãã math.floor(x) x - y
ãã¹ãã°ã©ã ã®è²ãã¹ããŒã«ãã plt.hist(ããŒã¿å, color='snow') plt.hist(ããŒã¿å, color='snow')
ãªãªãŒãã«ãã¹ãã°ã©ã ã®è²ãèšå®ãã plt.hist(ããŒã¿å, color='olive') plt.hist(ããŒã¿å, color='olive')
æååã®å
é ã®æåã䜿ã æåå[0] æåå[0]
䞡端ãã¥ãŒ 䞡端ãã¥ãŒ = collections.deque() 䞡端ãã¥ãŒ = collections.deque()
ãªã¹ãã®æåã䜿ã ãªã¹ã[0] ãªã¹ã[0]
éšåæååã§æååãäºåãã æåå.partition(éšåæåå) æåå.partition(éšåæåå)
ãªã¹ããäžå€®å€ã§ããã³ã°ãã pd.qcut(aList, 2) pd.qcut(aList, 2)
æ°ã3ä¹ãã x ** 3 x ** 3
option: ã°ã©ãã®ã©ã€ã³ã¹ã¿ã€ã«ãäžç¹éç·ã«èšå®ãã linestyle = 'dashbot' linestyle = 'dashbot'
tååžå確ççè¿ååã蟌ã¿æ³ã§èŠçŽ 次å
ã«æ¬¡å
åæžãã sklearn.manifold.TSNE(n_components=äº).fit_transform(å€æ¬¡å
ããŒã¿) sklearn.manifold.TSNE(n_components=äº).fit_transform(å€æ¬¡å
ããŒã¿)
3ã€ã®æã倧ããå€ãæ±ãã max(x, y, z) max(x, y, z)
è¡šããŒã¿ãã°ã«ãŒãåããæå°å€ãæ±ãã df.groupby('åA').min() df.groupby('åA').min()
ããŒã³ã°ãªãŒã³ã«ãã¹ãã°ã©ã ã®è²ããã plt.hist(ããŒã¿å, color='lawngreen') plt.hist(ããŒã¿å, color='lawngreen')
ããŒã¿ãã¬ãŒã ã®æå®ããã«ã©ã ãã©ã®çšåºŠãæ£èŠååžããå°ã£ãŠããã確èªãã df['åA'].skew() df['åA'].skew()
ã¢ã³ãµã³ãã«åŠç¿ãçšããŠã¯ã©ã¹åé¡ãè¡ã sklearn.ensemble.VotingClassifier() sklearn.ensemble.VotingClassifier()
ã©ã€ãã¹ã«ã€ãã«ãŒè²ã§çžŠæ£ã°ã©ããæç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='lightskyblue') plt.bar(ããŒã¿åx, ããŒã¿åy, color='lightskyblue')
ïŒã€äžŠã¹ãŠããŒã¿åããã¹ãã°ã©ã ã«ãã plt.hist([ããŒã¿å, ããŒã¿å, ããŒã¿å], color=['b', 'r'], 'g']) plt.hist([ããŒã¿å, ããŒã¿å, ããŒã¿å], color=['b', 'r', 'g'])
æãç·ã°ã©ãã®ãã€ã¢ã¢ã³ãå°ãèµ€ããã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='D', markerfacecolor='r') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='D', markerfacecolor='r')
ããŒã¿ã·ãªãŒãºã®äžååæ£ãèšç®ãã ds.var(ddof=1) ds.var(ddof=1)
æãç·ã°ã©ãã®ãã€ã³ãããŒã«ãŒãéè²ã«ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='.', markerfacecolor='b') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='.', markerfacecolor='b')
èŠçŽ ã®ç¡éå itertools.repeat(èŠçŽ ) itertools.repeat(èŠçŽ )
ã«ãŠã³ã¿ãèŸæžããäœã collections.Counter(aDict) collections.Counter(aDict)
ããã°ã©ã ãç°åžžæ¢ãã sys.exit(1) sys.exit(1)
æãç·ã°ã©ããã©ã€ã ã°ãªãŒã³è²ã䜿ã£ãŠæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='limegreen') plt.plot(ããŒã¿åx, ããŒã¿åy, color='limegreen')
æ£åžå³ã®å€§ããå°ãé»ããã plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='X', markerfacecolor='k') plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='X', markerfacecolor='k')
æžã蟌ã¿çšã«SJISã§ãã¡ã€ã«ããªãŒãã³ãã] open(filepath, mode='w', encoding='shift_jis') open(filepath, mode='w', encoding='shift_jis')
æãç·ã°ã©ããã·ã¹ã«è²ãšããŠæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='thistle') plt.plot(ããŒã¿åx, ããŒã¿åy, color='thistle')
ããŒã¿ãã¬ãŒã ã®ããåãåãåºã df['åA'] df['åA']
çŸåšã®æ¥ä»ãæ±ãã datetime.date.today().hour datetime.date.today()
ãã£ãŒãã¹ã«ã€ãã«ãŒè²ãšããŠæšªæ£ã°ã©ããæç»ãã plt.barh(ããŒã¿åx, ããŒã¿åy, color='deepskyblue') plt.barh(ããŒã¿åx, ããŒã¿åy, color='deepskyblue')
ããŒãèŸæžã«ååšããªãæãèŠçŽ ãè¿œå ãã èŸæž.setdefault(ããŒ, element) èŸæž.setdefault(ããŒ, element)
æå®ããã«ã©ã ã®æååãæ¬ æå€ã«ãã df['åA'].replace(å€, np.nan) df['åA'].replace(å€, np.nan)
è¡åã®çŽ¯ç©ç© np.cumprod(aArray, aArray2) np.cumprod(aArray)
äºã€ã®åããã°ã«ãŒãåããæå°å€ãæ±ãã df.groupby(['åA', 'åB'], as_index=False).min() df.groupby(['åA', 'åB'], as_index=False).min()
ãã¿ãŒã³ã«æååã®å
é ã§ASCIIéå®ãšããŠãããããã re.match(pattern, s, flags=re.ASCI) re.match(pattern, s, flags=re.ASCI)
ç®±é«å³ãæããå¹³åç·ãå ãã plt.boxplot(ããŒã¿å, meanline=True) plt.boxplot(ããŒã¿å, meanline=True)
暪æ¹åã«äºã€ã®ããŒã¿ãã¬ãŒã ãåäœããã pd.concat([df, df2], axis=1) pd.merge(df, df2)
èµ€ãç¹ç·ãšããŠããŒã¿åã®æšç§»ãæã plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dotted', color='r') plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dotted', color='r')
æ¿ãéè²ã§ãã¹ãã°ã©ã ãæç»ãã plt.hist(ããŒã¿å, color='darkblue') plt.hist(ããŒã¿å, color='darkblue')
æååãå
šãŠæ°åãã©ãã æåå.isdigit() æåå.isdigit()
ãµãã€ã®éåã®ã€ã³ã¿ãŒã»ã¯ã·ã§ã³ ã»ãã.intersection(ã»ãã2) ã»ãã.intersection(ã»ãã2)
æååã®éå§äœçœ®å
ã«éšåæååãããã調ã¹ã æåå.find(éšåæåå, éå§äœçœ®) == -1 æåå.find(éšåæåå, éå§äœçœ®) != -1
ããã«ã©ã ã®æååãéšåæååã§çµãããªãè¡ãæœåºãã df[~ df['åA'].str.endswith(éšåæåå)] df[~ df['åA'].str.endswith(éšåæåå)]
ãã¹ãã°ã©ã ãããã£ã¢ã ã¹ããªã³ã°ã°ãªãŒã³è²ã䜿ã£ãŠæç»ãã plt.hist(ããŒã¿å, color='mediumspringgreen') plt.hist(ããŒã¿å, color='mediumspringgreen')
option: ã©ã®è¡ãã«ã©ã ã®ååã«ããªã header = None header = None
æãç·ã°ã©ãã®å°ãäžžã«ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='o') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='o')
è¡åã®è¡ããšã®åèšå€ã䜿ã np.sum(aArray, axis=1) np.sum(aArray, axis=1)
æãç·ã°ã©ããåè§å°ãšããŠæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='s') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='s')
æååãæåŸã®ã³ãã³ã§äºåããŠåŸãã®æ¹ã䜿ã æåå.rpartition(':')[-1] æåå.rpartition(':')[-1]
option: ã°ã©ãã®è²ããã³ãã¯ãªãŒã ã«ã»ãããã color ='mintcream' color = 'mintcream'
CSVãã¡ã€ã«ã«ã«ã©ã ã®ååãä»ããããŒã¿ãã¬ãŒã ãä¿åãã df.to_csv('file.csv', header=None) df.to_csv('file.csv', header=None)
ããŒã¿ãã¬ãŒã ããåãïŒã€éžæãã df[['åA', 'åB', 'åC']] df[['åA', 'åB', 'åC']]
ããã°ã©ã ãç°åžžçµäºãã sys.exit(0) sys.exit(1)
å®æ°ã®nä¹ããŠå®æ°ã«ããäœããèšç®ãã pow(x, n, y) pow(x, n, y)
ãµãã€ã®éåã®å
±ééšåã䜿ã ã»ãã.intersection(ã»ãã2) ã»ãã.intersection(ã»ãã2)
option: ã©ã®åãã€ã³ããã¯ã¹ã«èšå®ããªã index_col = None index_col = None
æŽæ°ãäžæ¡ã®æ°ã -9 <= æŽæ° <= 9 0 <= æŽæ° <= 9
é»ããã€ã³ãããŒã«ãŒãšããŠæ£åžå³ãæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='.', c='k') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='.', c='k')
é¢æ°ã®å€ã«ãã£ãŠããŒã¿ãã¬ãŒã ãåé¡ãã df.groupby(é¢æ°) df.groupby(é¢æ°)
æååäžã«å°æåãå«ãŸããã any(c.islower() for c in æåå) any(c.islower() for c in æåå)
TSVããæåãšã³ã³ãŒãã£ã³ã°ãæå®ããŠèªã sys.stdin.read(1) pd.read_csv('file.tsv', sep='\t', encoding=æåãšã³ã³ãŒãã£ã³ã°)
ãã¹ãã°ã©ã ã®è²ããªãŒã«ãã¬ãŒã¹ã«å€æŽãã plt.hist(ããŒã¿å, color='oldlace') plt.hist(ããŒã¿å, color='oldlace')
ããŒã¿ã·ãªãŒãºã®æªå
¥åå€ãæ倧å€ã«èšå®ãã ds.fillna(ds.max()) ds.fillna(ds.max())
æŽæ°ããã€ãŸã§ãç¹°ãè¿ãã€ãã©ãã« itertools.repeat(æŽæ°) itertools.repeat(æŽæ°)
option: ãã¯ã€ãã¹ã¢ãŒã¯è²ãçšãã color = 'whitesmoke' color = 'whitesmoke'
æãç·ã°ã©ãã®è²ããªãªããã©ãã«æå®ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='olivedrab') plt.plot(ããŒã¿åx, ããŒã¿åy, color='olivedrab')
ã°ãªãŒã³ã€ãšããŒè²ã§ç·ã°ã©ããæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='greenyellow') plt.plot(ããŒã¿åx, ããŒã¿åy, color='greenyellow')
ããŒã¿ãã¬ãŒã ã®ããã«ã©ã ã®ç©ºæåããããããã df['åA'].replace('', np.nan).dropna() df['åA'].replace('', np.nan).dropna()
æãç·ã°ã©ãã®è²ãããžã£ãŒãã«ãŒã«å€æŽãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='dodgerblue') plt.plot(ããŒã¿åx, ããŒã¿åy, color='dodgerblue')
ããŒã¿ãã¬ãŒã ã®æå®ããã«ã©ã ã®äžã«æååãšæ¥ä»ããŒã¿ãããã€ãããæ°ãã df['åA'].isin([value, value2]).sum() df['åA'].isin([value, value2]).sum()
ããŒãèŸæžäžã§æªå®çŸ©ãã©ãã調ã¹ã ã㌠not in èŸæž ã㌠not in èŸæž
æãç·ã°ã©ãã®è²ãã²ã€ã³ãºããã«å€æŽãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='gainsboro') plt.plot(ããŒã¿åx, ããŒã¿åy, color='gainsboro')
å€ãå€ã«åŒ·ãç·åœ¢ååž°åæãè¡ã model = sklearn.linear_model.HuberRegressor() model = sklearn.linear_model.HuberRegressor()
ã¿ã³è²ãçšããŠãã¹ãã°ã©ã ãæç»ãã plt.hist(ããŒã¿å, color='tan') plt.hist(ããŒã¿å, color='tan')
ã³ãŒã©ã«è²ãšããŠæšªæ£ã°ã©ããæç»ãã plt.barh(ããŒã¿åx, ããŒã¿åy, color='coral') plt.barh(ããŒã¿åx, ããŒã¿åy, color='coral')
è€æ°ã®ã«ã©ã ããã°ã«ãŒãåããåæ£ãæ±ãã df.groupby(['åA', 'åB'], as_index=False).var() df.groupby(['åA', 'åB'], as_index=False).var()
option: èç«ã¬ã³ã¬ã«ãã©ã³ãã®è²ãèšå®ãã color = 'firebrick' color = 'firebrick'
ç·ã°ã©ããã¬ã¢ã³ã·ãã©ã³è²ã§æç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='lemonchiffon') plt.plot(ããŒã¿åx, ããŒã¿åy, color='lemonchiffon')
æµ®åå°æ°ç¹æ°ãè€çŽ æ°ã«å€æãã complex(x) complex(x)
ãã¹ãã°ã©ã ã®è²ãã³ãŒã³ãºã·ã«ã¯ã«æå®ãã plt.hist(ããŒã¿å, color='cornsilk') plt.hist(ããŒã¿å, color='cornsilk')
æãç·ã°ã©ããããã£ã¢ã ã·ã¢ã°ãªãŒã³è²ãšããŠæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='mediumseagreen') plt.plot(ããŒã¿åx, ããŒã¿åy, color='mediumseagreen')
æãç·ã°ã©ãã®ã¯ãã¹å°ãéããã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='x', markerfacecolor='b') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='x', markerfacecolor='b')
ããŒã¿ãL2ãã«ã ãšããŠæ£èŠåãã "sklearn.preprocessing.Normalizer(norm=""l2"").fit_transform(ããŒã¿å)" "sklearn.preprocessing.Normalizer(norm=""l2"").fit_transform(ããŒã¿å)"
æ£åžå³ããã©ã¬ã¹ãã°ãªãŒã³è²ãçšããŠæç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, color='forestgreen') plt.scatter(ããŒã¿åx, ããŒã¿åy, color='forestgreen')
æãç·ã°ã©ããã¢ã¯ã¢ããªã³è²ãšããŠæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='aquamarine') plt.plot(ããŒã¿åx, ããŒã¿åy, color='aquamarine')
ããŒã¿ã·ãªãŒãºãäžã®äœã§åæšäºå
¥ãã ds.round(-4) ds.round(-4)
ããŒã¿ãã¬ãŒã ã®æå®ããäºã€ã®åãåãåºã df['åA'].isin([value]) df[['åA', 'åB']]
ããã£ã¢ã ã·ã¢ã°ãªãŒã³è²ã§æ£åžå³ãæç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, color='mediumseagreen') plt.scatter(ããŒã¿åx, ããŒã¿åy, color='mediumseagreen')
æ£ã°ã©ããããŒã³ã¿è²ãšããŠæç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='magenta') plt.bar(ããŒã¿åx, ããŒã¿åy, color='magenta')
é
åãšãªã¹ãã«ã€ããŠæ£åžå³ãæç»ããŠãäžäžè§ããŒã«ãŒã®è²ãrgbã«èšå®ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='^', c=rgb) plt.plot(ããŒã¿åx, ããŒã¿åy, marker='^', c=rgb)
é
åã®æªã¿ãç®åºãã scipy.stats.skew(é
å, bias=False) scipy.stats.skew(é
å, bias=False)
ãããã®å€ã®äžèŠ§ èŸæž.values() list(èŸæž.values())
xãèµ€è²ã§è¡šç€ºãã print(f'\033[31m{x}\033[0m') print(f'\033[31m{x}\033[0m')
ã€ãã©ãã«ã暪æ£ã°ã©ãã«ãã plt.barh(ã©ãã«å, ããŒã¿å) plt.barh(ã©ãã«å, ããŒã¿å)
æãç·ã°ã©ãã®è²ãããŒã¯ã»ã¹ã©ãã°ã¬ãŒã«å€æŽãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='darkslategrey') plt.plot(ããŒã¿åx, ããŒã¿åy, color='darkslategrey')
ãããã®ããŒãèŠçŽ ã«å€æŽãã èŸæž[ããŒ] = element èŸæž[ããŒ] = element
ããŒã¿ãã¬ãŒã ã®éžæããåã®æ¬ æå€ãæ倧å€ã§åãã df[['åA', 'åB']].fillna(df[['åA', 'åB']].max()) df[['åA', 'åB']].fillna(df[['åA', 'åB']].max())
ããŒãã«è²ã§æšªæ£ã°ã©ããæç»ãã plt.barh(ããŒã¿åx, ããŒã¿åy, color='purple') plt.barh(ããŒã¿åx, ããŒã¿åy, color='purple')
ãã¥ãŒäžã®æŽæ°ã®ã€ã³ããã¯ã¹ 䞡端ãã¥ãŒ.index(æŽæ°) 䞡端ãã¥ãŒ.index(æŽæ°)
ãªã¹ãããã¹ãã°ã©ã ã«ãã plt.hist(ããŒã¿å) plt.hist(ããŒã¿å)
åºåãèšå·ã§æååãäºåãã æåå.partition(ã»ãã¬ãŒã¿) æåå.partition(ã»ãã¬ãŒã¿)
æãç·ã°ã©ãã«èµ€ãâœããŒã«ãŒãæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='v', markerfacecolor='r') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='v', markerfacecolor='r')
æŽæ°ãã©ã¹æŽæ°ãæ±ãã æŽæ° + æŽæ°2 æŽæ° + æŽæ°2
ããŒã¿ãã¬ãŒã ãé¢æ°ã®å€ã«ãã£ãŠã°ã«ãŒãåãèŠçŽçµ±èšéãèšç®ãã df.groupby(é¢æ°).describe() df.groupby(é¢æ°).describe()
暪æ£ã°ã©ããããŒã¯ã¹ã©ãã°ã¬ãŒè²ãšããŠæç»ãã plt.barh(ããŒã¿åx, ããŒã¿åy, color='darkslategray') plt.barh(ããŒã¿åx, ããŒã¿åy, color='darkslategray')
æ£åžå³ã«éãâœããŒã«ãŒãæç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='v', markerfacecolor='b') plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='v', markerfacecolor='b')
åånãåæ¯mã®æçæ°ãçæãã fractions.Fraction(numerator=n, denominator=m) fractions.Fraction(numerator=n, denominator=m)
ã¯ã©ã¹åé¡ã®äºæž¬ç²ŸåºŠãããŒããããã§ç¢ºèªãã sns.heatmap(confusion_matrix(æ£è§£ããŒã¿å, äºæž¬ããŒã¿å), annot=True, cmap='Reds') sns.heatmap(confusion_matrix(æ£è§£ããŒã¿å, äºæž¬ããŒã¿å), annot=True, cmap='Reds')
䞡端ãã¥ãŒã®é åºãå·Šã«ããŒããŒã·ã§ã³ãã 䞡端ãã¥ãŒ.rotate(-1) 䞡端ãã¥ãŒ.rotate(-1)
æååå
šäœããã¿ãŒã³ã«ããããããèŠã re.fullmatch(pattern, s) re.fullmatch(pattern, s)
option: ãªãŒãããã«ã°ã©ãã®è²ãæå®ãã color = 'orchid' color = 'orchid'
ã€ã³ãã³ãå¹
ãæå®ããŠæååãJSONæååã«å€æãã json.dumps(æåå, ensure_ascii=False, indent=n) json.dumps(æåå, ensure_ascii=False, indent=n)
ãµãã€ã®ãªã¹ãã®ç©éåãèšç®ãã list(set(ãªã¹ã).intersection(set(ãªã¹ã2))) list(set(ãªã¹ã).intersection(set(ãªã¹ã2)))
æååãã¿ã€ãã«ã±ãŒã¹ãã©ãã調ã¹ã æåå.istitle() æåå.istitle()
èŠçŽ ã¯ã¿ãã«ã®èŠçŽ ã§ãªãã確èªãã èŠçŽ not in ã¿ãã« èŠçŽ not in ã¿ãã«
æãç·ã°ã©ãã«ããããŒã«ãŒã䜿çšãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='x') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='x')
ããã£ã¢ã ã¿ãŒã³ã€ãºè²ã§æšªæ£ã°ã©ããæç»ãã plt.barh(ããŒã¿åx, ããŒã¿åy, color='mediumturquoise') plt.barh(ããŒã¿åx, ããŒã¿åy, color='mediumturquoise')
é
åããnåãµã³ããªã³ã°ããŠãªã¹ãåãã random.sample(é
å, k=n) random.sample(é
å, k=n)
ããŒã¿ãã¬ãŒã ã®æ¬ æå€ãæå°å€ã«æå®ãã df.fillna(df.min()) df.fillna(df.min())
option: ããŒã¯ãã«ãŒã«ãã©ã³ãã®è²ãå€æŽãã color = 'darkblue' color = 'darkblue'
å³ã«ããã¯ã®é åºãããŒããŒã·ã§ã³ãã 䞡端ãã¥ãŒ.rotate(1) 䞡端ãã¥ãŒ.rotate(1)
option: ãã¯ã€ãã¹ã¢ãŒã¯ã䜿çšãã color = 'whitesmoke' color = 'whitesmoke'
ã¯ã©ã¹åé¡ãã¹ã¿ããã³ã°ã§è¡ã sklearn.ensemble.StackingClassifier() sklearn.ensemble.StackingClassifier()
ããŒã¿ãã¬ãŒã ã®äžéšã®ã«ã©ã ã®ç©ºæåãæ¬ æå€ã«å€æãããããããã df[['åA', 'åB']].replace('', np.nan).dropna() df[['åA', 'åB']].replace('', np.nan).dropna()
æãç·ã°ã©ãã®è²ããããã«æå®ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='tomato') plt.plot(ããŒã¿åx, ããŒã¿åy, color='tomato')
ã©ã€ãã¹ã¬ã€ã°ã¬ãŒè²ã䜿ã£ãŠæ£åžå³ãæç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, color='lightslategray') plt.scatter(ããŒã¿åx, ããŒã¿åy, color='lightslategrey')
ãã¡ã€ã«ããã€ããªçšã«ãªãŒãã³ããŠ]fãšãã f = open(filepath, mode='rb') f = open(filepath, mode='rb')
ãªã¬ã³ãžã«ãã¹ãã°ã©ã ã®è²ãå€æŽãã plt.hist(ããŒã¿å, color='orange') plt.hist(ããŒã¿å, color='orange')
ãªã¹ãã®èŠçŽ ã®äœçœ®ããšã©ãŒãªãèŠã ãªã¹ã.index(èŠçŽ ) if (ãªã¹ã[1:] ãªã¹ã.index(èŠçŽ ) if èŠçŽ in ãªã¹ã else -1
瞊æ£ã°ã©ãã玺碧è²ã§æç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='azure') plt.bar(ããŒã¿åx, ããŒã¿åy, color='azure')
ã°ãªããã®ç·çš®ãç¹ç·ã«å€æŽãã plt.grid(linestyle='dotted') plt.grid(linestyle='dotted')
ãã¥ãŒäžã®æŽæ°ã®åºçŸæ°ãæ°ãã 䞡端ãã¥ãŒ.count(æŽæ°) 䞡端ãã¥ãŒ.count(æŽæ°)
暪æ£ã°ã©ããã¹ã¬ãŒããã«ãŒè²ãšããŠæç»ãã plt.barh(ããŒã¿åx, ããŒã¿åy, color='slateblue') plt.barh(ããŒã¿åx, ããŒã¿åy, color='slateblue')
ã¹ããŒè²ãšããŠæ£ã°ã©ããæç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='snow') plt.bar(ããŒã¿åx, ããŒã¿åy, color='snow')
æ¥ä»ããŒã¿ãšæ¥ä»ããŒã¿ã®æéå·®ãç®åºãã aDate - aDate2 aDate - aDate2
é
åããã©ããåãã aArray.flatten() aArray.flatten()
ããŒãã«è²ãšããŠæãç·ã°ã©ããæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='purple') plt.plot(ããŒã¿åx, ããŒã¿åy, color='purple')
ååäžèŠ§ãããŒã¿åã§ãã£ã«ã¿ãã df.select_dtypes(å).columns df.select_dtypes(å).columns
æãç·ã°ã©ãã®å°ãäžè§ã«ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='^') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='^')
æ°åãäžã€ã®æååã«ãã ''.join(map(str, æ°å)) ''.join(map(str, æ°å))
ãã¡ã€ã«ãã¹ãéããŠ]ããã€ããªã¹ããªãŒã ãæ±ãã 'rb' = 'a'<nl>open(filepath, mode='rb') 'rb' = 'a'<nl>open(filepath, mode='rb')
ããŒã¯ã«ãŒãè²ãšããŠæ£ã°ã©ããæç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='darkkhaki') plt.bar(ããŒã¿åx, ããŒã¿åy, color='darkkhaki')
ã€ãã©ãã«ããåæ¹åãã¥ãŒãäœã collections.deque(ã€ãã©ãã«) collections.deque(ã€ãã©ãã«)
ç·ã°ã©ãã®è²ããã¯ã·ã¢ã«èšå®ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='fuchsia') plt.plot(ããŒã¿åx, ããŒã¿åy, color='fuchsia')
ç·ã°ã©ãã®è²ãããŒãžãŒãã©ãŠã³ã«èšå®ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='rosybrown') plt.plot(ããŒã¿åx, ããŒã¿åy, color='rosybrown')
ããŒã¿ãã¬ãŒã ã®äžã®åãåå²æ°nã§ãã³åå²ãã pd.cut(df[col], n) pd.cut(df[col], n)
ããŒã³ã¿ã«ãã¹ãã°ã©ã ã®è²ãå€æŽãã plt.hist(ããŒã¿å, color='magenta') plt.hist(ããŒã¿å, color='magenta')
option: è²ãã¬ã¢ã³ã·ãã©ã³ã«ãã color = 'lemonchiffon' color = 'lemonchiffon'
æ¢åã®ãã¡ã€ã«ãæåã³ãŒãtextãšããŠè¿œå ã§ããããã«ãªãŒãã³ãã] open(filepath, mode='a', encoding=text) open(filepath, mode='a', encoding=text)
瞊æ£ã°ã©ããããŒã³ã°ãªãŒã³è²ã§æç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='lawngreen') plt.bar(ããŒã¿åx, ããŒã¿åy, color='lawngreen')
ç·ã°ã©ãããã«ãŒã³è²ã§æç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='maroon') plt.plot(ããŒã¿åx, ããŒã¿åy, color='maroon')
æååã®æåããæ¹è¡ãæ¶ã æåå.rstrip('\n') æåå.lstrip('\n')
æ«å°Ÿããæååãéšåæååã§åºåã æåå.rsplit() æåå.rsplit(éšåæåå)
æååãæå®ããæååã«å«ãŸããã調ã¹ã æåå in å¥ã®æåå æåå in å¥ã®æåå
æ倧å€ã»æå°å€ã®ç¯å²ã§äžæ§ãªçäŒŒä¹±æ° x = 0.0<nl>random.uniform(æå°å€, æ倧å€) x = 0.0<nl>x2 = 1.0<nl>random.uniform(æå°å€, æ倧å€)
è¡šããŒã¿ã®ããã«ã©ã ã®ææ¥ãäœæ¥ç®ãèŠã df['åA'].dt.dayofweek df['åA'].dt.dayofweek
åçãªãã®ç·åœ¢ã¢ãã«ãäœã model = sklearn.linear_model.LinearRegression(fit_intercept=False) model = sklearn.linear_model.LinearRegression(fit_intercept=False)
äºã€ã®ãªããžã§ã¯ãã¯åäžã調ã¹ã obj is obj2 obj is obj2
rgbã®å·Šäžè§ããŒã«ãŒãšããŠæ£åžå³ãæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='<', c=rgb) plt.plot(ããŒã¿åx, ããŒã¿åy, marker='<', c=rgb)
æååããªã¹ãã«å«ãŸããªãã æåå not in ãªã¹ã æåå not in ãªã¹ã
ã¿ãã«å
ã®èŠçŽ ã¯å
šãŠçãå€å®ãã all(ã¿ãã«) all(ã¿ãã«)
æ£åžå³ã®å°ã®è²ãå€æŽãã plt.scatter(ããŒã¿åx, ããŒã¿åy, markerfacecolor='#800080') plt.scatter(ããŒã¿åx, ããŒã¿åy, markerfacecolor='#800080')
å°æ°ç¹æ°ãç¡é倧ãã©ãã math.isinf(x) math.isinf(x)
èŠçŽ ã¯ã»ããã«å«ãŸããªãã èŠçŽ not in ã»ãã èŠçŽ not in ã»ãã
ã€ãã©ãã«ãšæ°åã«ã€ããŠæ£åžå³ãæç»ãããããŒã«ãŒãå·Šäžè§ã«èšå®ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='<') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='<')
å®è¡æã®æšæºåºåã®åºåå
ãã¿ãŒããã«ã sys.stdout.isatty() sys.stdout.isatty()
option: ã¹ããªã³ã°ã°ãªãŒã³ã«ã°ã©ãã®è²ãå€æŽãã color ='springgreen' color = 'springgreen'
åãã§ãªããšæžããã not æ¡ä»¶åŒ X != Y
ããŒã¿ãã¬ãŒã ã®ã«ã©ã ã®çžé¢ä¿æ°ãç®åºãã scipy.stats.pearsonr(df['åA'], df['åB']) scipy.stats.pearsonr(df['åA'], df['åB'])
éãç¹ç·ã§æ°åã®å€é·ããããããã plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dotted', color='b') plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dotted', color='b')
æèšåãã«åã°ã©ããæã plt.pie(ããŒã¿å, startangle=90, labels=ããŒã¿å) plt.pie(ããŒã¿å, startangle=90, counterclock=False)
ããŒããããã«ååšãããã©ãã調ã¹ã ã㌠not in èŸæž ã㌠in èŸæž
ãªã¬ã³ãžè²ã§çžŠæ£ã°ã©ããæç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='orange') plt.bar(ããŒã¿åx, ããŒã¿åy, color='orange')
nãããã€ãŸã§ãã«ãŠã³ãããŠã³ãã itertools.count(start=n, step=-1) itertools.count(start=n, step=-1)
ããŒã¿ãã¬ãŒã ã䜿ã import pandas as pd import pandas as pd
æååãæ¹è¡ã§åå²ãã æåå.splitlines() æåå.splitlines()
option: å°éºŠè²è²ãçšãã color = 'wheat' color = 'wheat'
é·ããäžèŽããªããšãã®zip 0<nl>f' - 10<nl>minutes(loc=(2, 4)) itertools.zip_longest(iterable, iterable2)
option: æååãåºåãèšå·ã§äœ¿ã sep = s sep = s
ããŒã¿åã®æãç·ã°ã©ãããã€ã³ãå°ã§æç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='.') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='.')
ã©ã€ã³ãåéæã®äžç¹éç·ã§æç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dashbot', alpha=0.5) plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dashbot', alpha=0.5)
æ°å€ãã»ããã®ãããã§ããªãã©ãã æ° not in ã»ãã æ° not in ã»ãã
ã·ãŒã±ã³ã¹ã2åãããããã«ã«ãç© itertools.product(iterable, repeat=2) itertools.product(iterable, repeat=2)
å
¥åããäºã€ã®å°æ°ãåãåºã A, B = map(float, input().split()) A, B = map(float, input().split())
æååãdatetime64åã«å€æãã æåå.replace(æåå, np.to_datetime) pd.to_datetime(æ¥ä»ãè¡šçŸããæåå)
æ°ãåã®äœã§äžžãã round(x, -1) round(x, -1)
ããŒã¿ãã¬ãŒã ã®å€ã¯æªå
¥åå€ã df.isna() df.isna()
ãµãã€ã®ã¿ãã«ãå ãã ã¿ãã« + ã¿ãã«2 ã¿ãã« + ã¿ãã«2
éç·è²ã䜿ã£ãŠæãç·ã°ã©ããæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='teal') plt.plot(ããŒã¿åx, ããŒã¿åy, color='turquoise')
æå®ããã«ã©ã ã®äžã«æ¥ä»ããŒã¿ãååšããã確èªãã df['åA'].isin([value]) df['åA'].isin([value])
ãã€ããŒè²ã䜿ã£ãŠæšªæ£ã°ã©ããæç»ãã plt.barh(ããŒã¿åx, ããŒã¿åy, color='navy') plt.barh(ããŒã¿åx, ããŒã¿åy, color='navy')
æãç·ã°ã©ãã®è²ãããã€ã€ãŠã£ããã«ã»ãããã plt.plot(ããŒã¿åx, ããŒã¿åy, color='papayawhip') plt.plot(ããŒã¿åx, ããŒã¿åy, color='papayawhip')
ãªãã³ã«ãã¹ãã°ã©ã ã®è²ãæå®ãã plt.hist(ããŒã¿å, color='linen') plt.hist(ããŒã¿å, color='linen')
èå¥åãæœè±¡ã¯ã©ã¹ã inspect.isabstract(èå¥å) inspect.isabstract(èå¥å)
æ±ç¶ã°ã©ããæç»ãããã³æ°ãæå®ãã plt.hist(ããŒã¿å, bins=åºé¢æ°) plt.hist(ããŒã¿å, bins=åºé¢æ°)
option: ã·ã¹ã«è²ã䜿çšãã color = 'thistle' color = 'thistle'
y軞ã®ç®çãæŽæ°ã®ã¿ã«ãã plt.yticks(np.arange(æå°å€, æ倧å€, éé)) plt.yticks(np.arange(æå°å€, æ倧å€, éé))
ããŒã¿ãã¬ãŒã ã®äžéšã®åãäžžããŠæŽæ°åã«ãã df[['åA', 'åB']].round().astype(int) df[['åA', 'åB']].round().astype(int)
ããŒã¿ãã¬ãŒã ã®èšè¿°çµ±èšéãèŠã df.describe() df.describe()
ã°ã©ãã®ãã¶ã€ã³ãããæãã«èšå®ãã sns.set() sns.set()
ããã£ã¢ã ã¿ãŒã³ã€ãºè²ãšããŠæ£åžå³ãæç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, color='mediumturquoise') plt.scatter(ããŒã¿åx, ããŒã¿åy, color='mediumturquoise')
èå¥åã¯ã¡ãœããã調ã¹ã inspect.ismethod(èå¥å) inspect.ismethod(èå¥å)
option: ã¿ãŒã³ã€ãºã«ãã©ã³ãã®è²ãèšå®ãã color = 'turquoise' color = 'turquoise'
æãç·ã°ã©ããã³ãŒã³ãã©ã¯ãŒãã«ãŒè²ã䜿ã£ãŠæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='cornflowerblue') plt.plot(ããŒã¿åx, ããŒã¿åy, color='cornflowerblue')
ããŒã¿ãã¬ãŒã ã®å€ã¯NaNã調ã¹ã df.isna() df.isna()
ãªããžã§ã¯ããååä»ãã¿ãã«ãã©ãã hasattr(obj, '_asdict') and hasattr(obj, '_fields') hasattr(obj, '_asdict') and hasattr(obj, '_fields')
ãã¡ã€ã«ãã¹ãæåã³ãŒãtextã§ãªãŒãã³ãã] text = 'utf-8'<nl>open(filepath, encoding=text) text = 'utf-8'<nl>open(filepath, encoding=text)
option: ã°ã©ãã®è²ãããŒã¯ã·ã¢ã³ã«æå®ãã color = 'darkcyan' color = 'darkcyan'
ãã¢ãœã³ãšããŠããŒã¿ãã¬ãŒã ã®çžé¢è¡åãæ±ãã df.corr(method='pearson') df.corr(method='pearson')
暪æ£ã°ã©ããã©ã€ãã°ã¬ãŒè²ã䜿ã£ãŠæç»ãã plt.barh(ããŒã¿åx, ããŒã¿åy, color='lightgray') plt.barh(ããŒã¿åx, ããŒã¿åy, color='lightgrey')
option: æžã蟌ã¿ã¢ãŒãã«æå®ãã mode = 'w' mode = 'w'
ããåã®æååãæ£èŠè¡šçŸã«ãããããè¡ãéžã¶ df[df['åA'].str.match(æ£èŠè¡šçŸ)] df[df['åA'].str.match(æ£èŠè¡šçŸ)]
é
åã®æå°ãæ±ãã np.min(é
å) np.min(aArray)
æ£åžå³ãããŒã¯ãªãŒãããè²ãçšããŠæç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, color='darkorchid') plt.scatter(ããŒã¿åx, ããŒã¿åy, color='darkorchid')
æãç·ã°ã©ãããªã¬ã³ãžã¬ããè²ã䜿ã£ãŠæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='orangered') plt.plot(ããŒã¿åx, ããŒã¿åy, color='orangered')
暪æ£ã°ã©ããããã£ã¢ã ã·ã¢ã°ãªãŒã³è²ãšããŠæç»ãã plt.barh(ããŒã¿åx, ããŒã¿åy, color='mediumseagreen') plt.barh(ããŒã¿åx, ããŒã¿åy, color='mediumseagreen')
ãã¹ãã°ã©ã ã®è²ããµã³ãã£ãŒãã©ãŠã³ã«æå®ãã plt.hist(ããŒã¿å, color='sandybrown') plt.hist(ããŒã¿å, color='sandybrown')
ããŒã¿ãã¬ãŒã ã®äžéšã®ã«ã©ã ã®å¹³åå€ãæ±ãã df[['åA', 'åB']].mean() df[['åA', 'åB']].mean()
éšåæååãæååã®æå®ããåºéã«ååšããã æåå.find(éšåæåå, éå§äœçœ®, çµäºäœçœ®)!= -1 æåå.find(éšåæåå, éå§äœçœ®, çµäºäœçœ®) != -1
éè€ããè¡ã ããåãåºã df[df.duplicated(keep=False)] df[df.duplicated(keep=False)]
é»ããã€ã³ãããŒã«ãŒã§æ£åžå³ãæã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='.', c='k') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='.', c='k')
äºã€ã®ããŒã¿ãã¬ãŒã ãç°ãªãåãããŒãšããŠå
éšçµåãã pd.merge(df, df2, left_on='åA', right_on='åB', how='inner') pd.merge(df, df2, left_on='åA', right_on='åB', how='inner')
æååãåºåãèšå·ã§åå²ããŠãåæãã æåå.split(ã»ãã¬ãŒã¿) æåå.split(ã»ãã¬ãŒã¿)
å€ãå€ãé€ããé
åã®åæ£ scipy.stats.tvar(é
å, limits=(äžé, äžé), inclusive=(True, True)) scipy.stats.tvar(é
å, limits=(äžé, äžé), inclusive=(True, True))
èªã¿èŸŒã¿çšã«ãã¡ã€ã«ããªãŒãã³ããŠ]ãfãšãã f = open(filepath, mode='r') f = open(filepath, mode='r')
æ£åžå³ã«é»ãäžžå°ãæç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='o', markerfacecolor='k') plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='o', markerfacecolor='k')
æåãå¥ã®æååã«ããã æå in æåå æå in æåå
ãããããéè²ãçšããŠæ£åžå³ãæç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, color='cornflowerblue') plt.scatter(ããŒã¿åx, ããŒã¿åy, color='cornflowerblue')
äºã€ã®ã»ãããäºãã«çŽ ã»ãã.isdisjoint(ã»ãã2) ã»ãã.isdisjoint(ã»ãã2)
option: ãã©ã³ãã®è²ãã«ããããã«ãŒã«å€æŽãã color = 'cadetblue' color = 'cadetblue'
ããŒã¿ãã¬ãŒã ãæå®ããåã®å€æ¯ã«ã°ã«ãŒãåããŠãåæãã [(name, group_df) for name, group_df in df.groupby('åA')] [(name, group_df) for name, group_df in df.groupby('åA')]
æ¹è¡ãªãã«ïŒã€ã®å€æ°ãããªã³ããã print(å€æ°å, å€æ°å, end='') print(å€æ°å, å€æ°å, end='')
暪æ£ã°ã©ããé»è²è²ãçšããŠæç»ãã plt.barh(ããŒã¿åx, ããŒã¿åy, color='yellow') plt.barh(ããŒã¿åx, ããŒã¿åy, color='yellow')
predicateFuncãTrueãšãªãã€ãã©ãã«ã®èŠçŽ ãåŸã itertools.takewhile(predicateFunc, iterable) itertools.takewhile(predicateFunc, iterable)
ãã¹ãã°ã©ã ãã¢ã€ããªãŒè²ãšããŠæç»ãã plt.hist(ããŒã¿å, color='ivory') plt.hist(ããŒã¿å, color='ivory')
äºã€ã®éåã®ããããäžæ¹ã ãã®éå ã»ãã.symmetric_difference(ã»ãã2) ã»ãã.symmetric_difference(ã»ãã2)
æååããäžã€ãã€æåãåæãã [æåå].astype(æåå) list(æåå)
éå§äœçœ®ããçµäºäœçœ®ãŸã§ã«éšåæååãããã€ãååšããã調ã¹ã æåå.count(éšåæåå, éå§äœçœ®, çµäºäœçœ®) æåå.count(éšåæåå, éå§äœçœ®, çµäºäœçœ®)
暪æ£ã°ã©ããæç»ããŠãããŒã®çžŠå¹
ãèšå®ãã plt.barh(ã©ãã«å, ããŒã¿å, width=0.5) plt.barh(ã©ãã«å, ããŒã¿å, width=0.5)
èå¥åã¯ã¹ã¿ãã¯ãã¬ãŒã ã調ã¹ã inspect.isframe(èå¥å) inspect.isframe(èå¥å)
é»ã倧ããããŒã«ãŒãæ£åžå³ã«æç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='X', markerfacecolor='k') plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='X', markerfacecolor='k')
ããŒã¿ãã¬ãŒã ã®äžéšã®ã«ã©ã ã®å°åºŠ df[['åA', 'åB']].skew() df[['åA', 'åB']].skew()
è±åã®å€§æåå string.ascii_uppercase string.ascii_uppercase
è¡šãã°ã«ãŒãåããããã«ã©ã ã«å¯Ÿãå¹³åå€ãæ±ãã df.groupby('åA')['åB'].mean() df.groupby('åA')['åB'].mean()
æååã®å·ŠåŽããæåãåãé€ã æåå.lstrip(æå) æåå.lstrip(æå)
option: ããã£ã¢ã ã¹ã¬ãŒããã«ãŒã䜿ã color ='mediumslateblue' color = 'mediumslateblue'
å¥èªç¹æåãå
šéšèŠã string.punctuation string.punctuation
ããŒã¿ãã¬ãŒã ã®NaNãæ°å€ã§çœ®ãæãã df.fillna(x) df.fillna(x)
æ£åžå³ã®äžäžè§ããŒã«ãŒã®å€§ãããå€ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='v', markersize=2.0) plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='v', markersize=2.0)
æ£åžå³ãããŒã¯ã°ã¬ãŒè²ãçšããŠæç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, color='darkgray') plt.scatter(ããŒã¿åx, ããŒã¿åy, color='darkgray')
暪æ£ã°ã©ããããããããŠãäžå¯ããã plt.barh(ã©ãã«å, ããŒã¿å, align='edge') plt.barh(ã©ãã«å, ããŒã¿å, align='edge')
ããŒã¿ãã¬ãŒã ããã©ã³ãã ã«100è¡ãéè€ããã§ãµã³ããªã³ã°ãã df.sample(100, replace=True) df.sample(100, replace=True)
䞡端ãã¥ãŒã®äžéé· äž¡ç«¯ãã¥ãŒ.maxlen 䞡端ãã¥ãŒ.maxlen
æååã®å³åŽããéšåæååãæ¶ã æåå.rstrip(éšåæåå) æåå.rstrip(éšåæåå)
ååž°ã¢ãã«ã®æ®å·®ãæ±ãã sklearn.metrics.precision_score(ç®çå€æ°, model.predict(説æå€æ°)) ç®çå€æ° - model.predict(説æå€æ°)
ããŒã¿ã·ãªãŒãºãçŸã®äœã§äžžããŠæŽæ°åã«ãã ds.round(-2).astype(int) ds.round(-2).astype(int)
ãã¯ãã«ã®èŠçŽ æ° len(aArray) aArray.size
ãã¡ã€ã«ãæžã蟌ã¿ã§ããããã«éã] 'w' = 'a'<nl>open(filepath, mode='w') 'w' = 'a'<nl>open(filepath, mode='w')
å°ããæ¹ã欲ãã min(X, Y) min(X, Y)
option: ããŒã¯ã°ã¬ãŒãçšãã color = 'darkgray' color = 'darkgray'
éè²ã§xãåºåãã print(f'\033[34m{x}\033[0m') print(f'\033[34m{x}\033[0m')
æ£åžå³ãrgbã®å€§ããããŒã«ãŒãšããŠãããããã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='X', c=rgb) plt.plot(ããŒã¿åx, ããŒã¿åy, marker='X', c=rgb)
option: ããŒã«ãŒãè±åœ¢ã«æå®ãã marker = 'D' marker = 'D'
ã«ããŽãªããŒã¿ããã¯ãã«åãã sklearn.preprocessing.LabelEncoder().fit_transform(ããŒã¿å) sklearn.preprocessing.OneHotEncoder(sparse=False).fit_transform(ããŒã¿å)
ã»ããã®æµ
ãã³ããŒãäœã ã»ãã.copy() ã»ãã.copy()
æååããã¿ãŒã³ã«ãã£ãŠçœ®æãã re.sub(pattern, newsub, s) re.sub(pattern, newsub, s)
æååäžã«å€§æåããªããã©ãã any(not c.isupper() for c in æåå) any(not c.isupper() for c in æåå)
瞊æ£ã°ã©ãããã¹ãã£ããŒãºè²ã§æç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='mistyrose') plt.bar(ããŒã¿åx, ããŒã¿åy, color='mistyrose')
ã¬ããã«ããŒãã«ã«ãã¹ãã°ã©ã ã®è²ãèšå®ãã plt.hist(ããŒã¿å, color='rebeccapurple') plt.hist(ããŒã¿å, color='rebeccapurple')
ãã¹ãã°ã©ã ãããŒã¯ãªã¬ã³ãžè²ã䜿ã£ãŠæç»ãã plt.hist(ããŒã¿å, color='darkorange') plt.hist(ããŒã¿å, color='darkorange')
ãªã¬ã³ãžè²ãšããŠæšªæ£ã°ã©ããæç»ãã plt.barh(ããŒã¿åx, ããŒã¿åy, color='orange') plt.barh(ããŒã¿åx, ããŒã¿åy, color='orange')
æµ®åå°æ°ç¹æ°ä»¥äžã®æå°ã®æŽæ° min(x, y) math.ceil(x)
ç¯å²ãæå®ããŠä¹±æ°ãæ±ãã random.randint(æå°å€, æ倧å€) random.randint(æå°å€, æ倧å€)
æãç·ã°ã©ãã®è²ãã°ãªãŒã³ã€ãšããŒã«å€æŽãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='greenyellow') plt.plot(ããŒã¿åx, ããŒã¿åy, color='greenyellow')
æŽæ°ã1ãããã¯2 æŽæ° == 1 or æŽæ° == 2 æŽæ° == 1 or æŽæ° == 2
äžé
æŒç®åãæžããã X + Y X if æ¡ä»¶åŒ else Y
æãç·ã°ã©ãã®ã¯ãã¹ããŒã«ãŒã®è²ãå€ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='x', markerfacecolor='#800080') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='x', markerfacecolor='#800080')
ããŒã¿ãã¬ãŒã ã®ããŒã¿åãªã¹ãã䜿ã df.dtypes df.dtypes
ã·ã«ããŒã«ãã¹ãã°ã©ã ã®è²ãèšå®ãã plt.hist(ããŒã¿å, color='silver') plt.hist(ããŒã¿å, color='silver')
ãªã¹ããšé
åã«ã€ããŠæ£åžå³ãæç»ããŠãâŒããŒã«ãŒã®è²ãrgbã«å€æŽãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='v', c=rgb) plt.plot(ããŒã¿åx, ããŒã¿åy, marker='v', c=rgb)
èŠçŽ ã¯ã¿ãã«ã®èŠçŽ ã§ãªã èŠçŽ not in ã¿ãã« èŠçŽ not in ã¿ãã«
option: è²ãããã£ã¢ã ã¹ããªã³ã°ã°ãªãŒã³ã«å€æŽãã color ='mediumspringgreen' color = 'mediumspringgreen'
å¹³åãšåæ£ã§æšæºåãè¡ã sklearn.preprocessing.StandardScaler().fit_transform(ããŒã¿) sklearn.preprocessing.StandardScaler().fit_transform(ããŒã¿)
ç¡éã«æŽæ°ãç¶ãã€ãã©ãã«ã䜿ã itertools.repeat(æŽæ°) itertools.repeat(æŽæ°)
ããŒã¿ãã¬ãŒã ãäºã€ã®åã«ãã£ãŠå€§ããé ã«ç Žå£çã«ãœãŒããã df.sort_values(by=['åA', 'åB'], ascending=False, inplace=True) df.sort_values(by=['åA', 'åB'], ascending=False, inplace=True)
BOMä»ãã§ãã¡ã€ã«ãã¹ãæžã蟌ã¿çšã«éã] open(filepath, mode='w', encoding='utf_8_sig') open(filepath, mode='w', encoding='utf_8_sig')
æååã®æå®ããç¯å²äœçœ®ã®éã«éšåæååãå«ãŸãããã©ãã æåå.find(éšåæåå, éå§äœçœ®, çµäºäœçœ®)!= -1 æåå.find(éšåæåå, éå§äœçœ®, çµäºäœçœ®) != -1
ãã¹ãã°ã©ã ã®è²ãã€ãšããŒã°ãªãŒã³ã«å€æŽãã plt.hist(ããŒã¿å, color='yellowgreen') plt.hist(ããŒã¿å, color='yellowgreen')
ããããã³ã¯è²ã§ç·ã°ã©ããæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='hotpink') plt.plot(ããŒã¿åx, ããŒã¿åy, color='hotpink')
ç·ã°ã©ããããããã³ã¯è²ã§æç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='hotpink') plt.plot(ããŒã¿åx, ããŒã¿åy, color='hotpink')
è¶è²è²ã§ãã¹ãã°ã©ã ãæç»ãã plt.hist(ããŒã¿å, color='brown') plt.hist(ããŒã¿å, color='brown')
æ¥ä»ããŒã¿ãæ°Žææ¥ãã©ãã aDate.weekday() == 2 aDate.weekday() == 2
option: ã°ã©ãã®è²ãã¹ã«ã€ãã«ãŒã«å€æŽãã color ='skyblue' color = 'skyblue'
ãªããžã§ã¯ãã®å isinstance(obj, type=1) type(obj)
æ£ã°ã©ãããããŒãã¥ãŒè²ãšããŠæç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='honeydew') plt.bar(ããŒã¿åx, ããŒã¿åy, color='honeydew')
ããŒã¿ãã¬ãŒã ã®è¡åãå
šãŠä»ãçŽã df.rename(index={x: y}) df.rename(index={x: y})
æ¹è¡ãªãã«xãåºåãã print(x, end='') print(x, end='')
æ¬æ¥ã®ææ°ãèŠã datetime.datetime.today().month datetime.datetime.today().month
é
åã®ããªã å¹³åãç®åºãã scipy.stats.tmean(é
å, limits=(äžé, äžé), inclusive=(True, True)) scipy.stats.tmean(é
å, limits=(äžé, äžé), inclusive=(True, True))
ããŒã¿ãã¬ãŒã ãåã«ããŽãªã«ã°ã«ãŒãåããŠãã€ãªãªã³å³ã«ãã sns.violinplot(x='ã«ããŽãªå', y='å', hue='ã«ããŽãªå', data=df) sns.violinplot(x='ã«ããŽãªå', y='å', data=df)
ååãæå®ããŠããŒã¿ãã¬ãŒã ãå
šçµåãã pd.merge(df, df2, on='åA', how='outer') pd.merge(df, df2, on='åA', how='outer')
æãç·ã°ã©ããã¢ã³ãã£ãŒã¯ãã¯ã€ãè²ãçšããŠæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='antiquewhite') plt.plot(ããŒã¿åx, ããŒã¿åy, color='antiquewhite')
ç·ã°ã©ããã¢ã€ããªãŒè²ãšããŠæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='ivory') plt.plot(ããŒã¿åx, ããŒã¿åy, color='ivory')
ã¹ã«ã€ãã«ãŒè²ã®æãç·ã°ã©ããæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='skyblue') plt.plot(ããŒã¿åx, ããŒã¿åy, color='skyblue')
ãŽãŒã«ãè²ã§ãã¹ãã°ã©ã ãæç»ãã plt.hist(ããŒã¿å, color='gold') plt.hist(ããŒã¿å, color='gold')
æ£åžå³ãäžžå°ã§æç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='o') plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='o')
ããŒã¿ãã¬ãŒã ã®ã²ãšã€ã®ã«ã©ã ã ã説æå€æ°ã«ãã 説æå€æ° = df[['åå']] 説æå€æ° = df[['åå']]
æååãã³ãã³ã§äºåå²ããŠååãèŠã æåå.partition(':')[0] æåå.partition(':')[0]
ã·ã³ãã«èšç®ã䜿ã math.Symbol(x) import sympy
ã°ã©ãã«æ°Žå¹³æ¹åã®äžç¹éç·ãã€ãã plt.axhline(y=0, linestyle='dashbot') plt.axhline(y=0, linestyle='dashbot')
ã»ããããå
šãŠã®èŠçŽ ãæ¶ã ã»ãã.clear() ã»ãã.clear()
é
åãã²ãšã€ã®æååã«ãã ''.join(map(str, é
å)) ''.join(map(str, é
å))
rgbã®â²ããŒã«ãŒãšããŠæ£åžå³ããããããã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='^', c=rgb) plt.plot(ããŒã¿åx, ããŒã¿åy, marker='^', c=rgb)
æååã®å
é ã§æ£èŠè¡šçŸã«è€æ°è¡å¯Ÿå¿ãšããŠãããããã確èªãã re.match(pattern, s, flags=re.MULTILINE) re.match(pattern, s, flags=re.MULTILINE)
ããŒã¿ã·ãªãŒãºã®æ¬ æå€ãæ倧å€ã«å€æŽãã ds.fillna(ds.max()) ds.fillna(ds.max())
äºã€ã®åã«ãã£ãŠããŒã¿ãã¬ãŒã ããŸãšããè¡šã䜿ã df.groupby(['åA', 'åB']) df.groupby(['åA', 'åB'])
ããŒã¿ãã¬ãŒã ã®nè¡ç®ãåãåºã df.head(n) df.loc[n]
é»ãæããŒã«ãŒãçšããŠæ£åžå³ãæã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='*', c='k') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='*', c='k')
äºä¹ãæžããã X ** 5 X ** 5
ããããã³ã¯è²ãçšããŠçžŠæ£ã°ã©ããæç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='hotpink') plt.bar(ããŒã¿åx, ããŒã¿åy, color='hotpink')
option: ã¢ã¯ã¢ã«ã°ã©ãã®è²ãèšå®ãã color = 'aqua' color = 'aqua'
ãªã¹ããšãªã¹ãã«ã€ããŠæ£åžå³ãæç»ãããããŒã«ãŒãæã«å€æŽãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='*') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='*')
option: ã·ã¹ã«ã䜿ã color = 'thistle' color = 'thistle'
ãã©ãã¯è²ã®çžŠæ£ã°ã©ããæç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='black') plt.bar(ããŒã¿åx, ããŒã¿åy, color='black')
æŽæ°ã®å
«åã®äžãç®åºãã æŽæ° / 8 æŽæ° / 8
æ¡ä»¶æŒç®åãæžããã X == Y X if æ¡ä»¶åŒ else Y
è€æ°è¡å¯Ÿå¿ãšããŠäºåã«ãã¿ãŒã³ãã³ã³ãã€ã«ãã re.compile(pattern, flag=re.MULTILINE) re.compile(pattern, flag=re.MULTILINE)
option: ããã£ã¢ã ã¿ãŒã³ã€ãºè²ã䜿çšãã color ='mediumturquoise' color = 'mediumturquoise'
æ£åžå³ãäžäžè§å°ã§æç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='v') plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='v')
æååäžã«é空çœãããã調ã¹ã any(not c.isspace() for c in æåå) any(not c.isspace() for c in æåå)
option: ããŒã¯ãã«ãŒè²ãçšãã color = 'darkblue' color = 'darkblue'
ããŒã¿ãã¬ãŒã ã®æªå
¥åå€ãçŽåŸã®å€ã«èšå®ãã df.fillna(method='bfill') df.fillna(method='bfill')
ã¬ãŠã¹éçšã䜿ã£ãŠã¯ã©ã¹åé¡ããã model = sklearn.gaussian_process.GaussianProcessClassifier() model = sklearn.gaussian_process.GaussianProcessClassifier()
æ£åžå³ã®âœããŒã«ãŒã®ç·å¹
ãå€ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='v', markeredgewidth=2.5) plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='v', markeredgewidth=2.5)
ã°ã©ãã®äžã®çžŠè»žã«è»žåãä»ãã plt.ylabel('y軞ã©ãã«') plt.ylabel('y軞ã©ãã«')
æååã®éå§äœçœ®ä»¥éãsubã§å§ãŸããã©ãã調ã¹ã æåå.startswith(éšåæåå, éå§äœçœ®) æåå.startswith(éšåæåå, éå§äœçœ®)
ããŒã¿ãã¬ãŒã ããåãªã¹ãã§æå®ãããããŒã¿åã®åã®ã¿åãåºã df.select_dtypes(include=typeList) df.select_dtypes(include=typeList)
year幎monthædayæ¥houræminuteåãæ¥ä»æå»ã«ãã datetime.datetime(year=year, month=month, day=day, hour=hour, minute=minute) datetime.datetime(year=year, month=month, day=day, hour=hour, minute=minute)
ã©ã€ãã°ãªãŒã³è²ã§æ£ã°ã©ããæç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='lightgreen') plt.bar(ããŒã¿åx, ããŒã¿åy, color='lightseagreen')
äžå€®å€ã§ããŒã¿åããã³åå²ãã pd.qcut(ds, 2) pd.qcut(ds, 2)
ãã¡ã€ã«ããJSON圢åŒã®ããŒã¿ãèªã¿èŸŒã with open('file.json') as f:<nl><tab>data = json.load(f) with open('file.json') as f:<nl><tab>data = json.load(f)
é
åãnåã«åå²ããŠãnamesã®ã©ãã«ãã€ãã pd.cut(aArray, n, labels=names) pd.cut(aArray, n, labels=names)
暪æ£ã°ã©ããã«ããããã«ãŒè²ãçšããŠæç»ãã plt.barh(ããŒã¿åx, ããŒã¿åy, color='cadetblue') plt.barh(ããŒã¿åx, ããŒã¿åy, color='cadetblue')
option: ã¢ã€ããªãŒã䜿ã color = 'ivory' color = 'ivory'
èŸæžã®å€ã«èŠçŽ ã¯å«ãŸããŠããªãã element not in èŸæž.values() element not in èŸæž.values()
å€æ°èšç®ã䜿ã import pandas as pd import sympy
ããŒã¿ãã¬ãŒã ã®æªã¿ df.kurt() df.kurt()
ã€ãã©ãã«ã®ã€ãã¥ãŒã¿ãã«ãªéåãæºåãã frozenset(ã€ãã©ãã«) frozenset(ã€ãã©ãã«)
ãã¡ã€ã«ãã¹ã®ãã£ã¬ã¯ããªåãæ±ãã os.path.dirname(filepath) os.path.dirname(filepath)
ããŒã¿åãšãªã¹ãã«ã€ããŠã®æ£åžå³ã«é»ãäžžããŒã«ãŒãæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='o', c='k') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='o', c='k')
ã»ãããäžäœéåã調ã¹ã ã»ãã.issuperset(ã»ãã2) ã»ãã.issuperset(ã»ãã2)
瞊æ£ã°ã©ããããŠããŒãã«ãŒè²ã§æç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='powderblue') plt.bar(ããŒã¿åx, ããŒã¿åy, color='powderblue')
ããŒã¿ãã¬ãŒã ã®éžæããã«ã©ã ã®äžã«ãããšæååã®åèšãæ°ãã df[['åA', 'åB']].isin([value, value2]).sum() df[['åA', 'åB']].isin([value, value2]).sum()
æååäžã®ã¿ãã空çœã«ãã æåå.expandtabs(tabsize=n) æåå.expandtabs(tabsize=n)
ããŒã³ã¿è²ã§ãã¹ãã°ã©ã ãæç»ãã plt.hist(ããŒã¿å, color='magenta') plt.hist(ããŒã¿å, color='magenta')
å€æ¬¡å
ããŒã¿ãSVDãšããŠæåå次å
ã«åæžãã sklearn.decomposition.TruncatedSVD(n_components=N).fit_transform(å€æ¬¡å
ããŒã¿) sklearn.decomposition.TruncatedSVD(n_components=N).fit_transform(å€æ¬¡å
ããŒã¿)
ããŒã¿ãã¬ãŒã ã®ä»£è¡šå€ df.mode() df.describe()
ããã£ã¢ã ããŒãã«è²ã§æšªæ£ã°ã©ããæç»ãã plt.barh(ããŒã¿åx, ããŒã¿åy, color='mediumpurple') plt.barh(ããŒã¿åx, ããŒã¿åy, color='mediumpurple')
ããç®ã®ããŸãã®èšç®ãæžããã X % Y X % Y
ã¯ãªã ãŸã³è²ã§çžŠæ£ã°ã©ããæç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='crimson') plt.bar(ããŒã¿åx, ããŒã¿åy, color='crimson')
空ã®ãããœååž°ã¢ãã«ãçšæãã model = sklearn.linear_model.Rosso(alpha=æ£ååé
) model = sklearn.linear_model.Rosso(alpha=æ£ååé
)
ããŒã¿ãã¬ãŒã ã2ã€ã®ã«ã©ã ã®å€æ¯ã«ã°ã«ãŒãåããŠãåæãã [(name, group_df) for name, group_df in df.groupby(['åA', 'åB'])] [(name, group_df) for name, group_df in df.groupby(['åA', 'åB'])]
ç®±ã²ãå³ãæç»ããŠå¹³åãå ãã plt.boxplot(ããŒã¿å, showmeans=True) plt.boxplot(ããŒã¿å, showmeans=True)
瞊æ£ã°ã©ããã°ã¬ãŒè²ã§æç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='gray') plt.bar(ããŒã¿åx, ããŒã¿åy, color='grey')
ã°ã©ãã§çšãã瞊軞ã®ã©ãã«ãuntitledã«å€æŽãã plt.ylabel('y軞ã©ãã«') plt.ylabel('y軞ã©ãã«')
å®æ°ã®æŽæ°éšãèšç®ãã math.modf(x)[0] math.modf(x)[1]
ç·ã°ã©ããã¹ã«ã€ãã«ãŒè²ã§æç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='skyblue') plt.plot(ããŒã¿åx, ããŒã¿åy, color='skyblue')
option: ããŒã¯ãµãŒã¢ã³ã«ã°ã©ãã®è²ãèšå®ãã color = 'darksalmon' color = 'darksalmon'
ããŒã¿ãã¬ãŒã ã®äžã®ã«ã©ã ãçééã§nåã«ãã³åå²ãã pd.cut(df[col], n) pd.cut(df[col], n)
æŽæ°åã®ãŒãåããããè¡å np.zeros(èŠçŽ æ°, dtype=np.int) np.zeros(èŠçŽ æ°, dtype=np.int)
ããŒã¿ãã¬ãŒã ã®åã®åããŒã¿å€ã®åºçŸæ°ãæ±ãã df[col].value_counts() df[col].value_counts()
ã«ãŒãè²ãçšããŠæãç·ã°ã©ããæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='khaki') plt.plot(ããŒã¿åx, ããŒã¿åy, color='khaki')
æååã®nçªç®ãã¢ã¹ããŒã³ãŒãã«ãã ord(æåå[n]) ord(æåå[n])
æ£åžå³ãã©ã€ããã«ãŒè²ãšããŠæç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, color='lightblue') plt.scatter(ããŒã¿åx, ããŒã¿åy, color='lightblue')
ããŒã¿ãã¬ãŒã ã®éžæããã«ã©ã ã¯ã©ã®çšåºŠãæ£èŠååžããæªãã§ããã調ã¹ã df[['åA', 'åB']].kurt() df[['åA', 'åB']].kurt()
ããŒã¿ãã¬ãŒã ã®éžæããã«ã©ã ã®æªå
¥åå€ãæå°å€ã«èšå®ãã df[['åA', 'åB']].fillna(df[['åA', 'åB']].min()) df[['åA', 'åB']].fillna(df[['åA', 'åB']].min())
å®æ°ãæµ®åå°æ°ç¹æ°ã§é€ããäœã x % y x % y
å®æ°ã®éåæ²ç·äœåŒŠãæ±ãã math.acosh(x) math.acosh(x)
option: ç·ã®çš®é¡ãå®ç·ã«å€æŽãã linestyle ='solid' linestyle = 'solid'
暪æ£ã°ã©ããã©ã€ããŽãŒã«ãããã£ã€ãšããŒè²ãšããŠæç»ãã plt.barh(ããŒã¿åx, ããŒã¿åy, color='lightgoldenrodyellow') plt.barh(ããŒã¿åx, ããŒã¿åy, color='lightgoldenrodyellow')
æååäžã«ç©ºçœãå«ãŸãã any(c.isspace() for c in æåå) any(c.isspace() for c in æåå)
ããŒã¿ãã¬ãŒã ããåãè¡ãæ¶ã df.drop_duplicates(axis=1) df.drop_duplicates(inplace=True)
åä¹ãèšç®ããã X ** 4 X ** 4
ãã¯ãã«ã®å aArray + aArray2 aArray + aArray2
Pandasã®æ¥ä»åã®ããŒã¿ã·ãªãŒãºãããŒã¿ãã¬ãŒã ã®ã€ã³ããã¯ã¹ã«ãã df.index = pd.DatetimeIndex(ds) df.index = pd.DatetimeIndex(ds)
ä»æ¥ã®æ¥ã䜿ã datetime.datetime.today().day datetime.datetime.today().day
暪æ£ã°ã©ãããµã³ãã£ãŒãã©ãŠã³è²ã䜿ã£ãŠæç»ãã plt.barh(ããŒã¿åx, ããŒã¿åy, color='sandybrown') plt.barh(ããŒã¿åx, ããŒã¿åy, color='sandybrown')
å°æ°ç¹ä»¥äž'5'æ¡ãŸã§è¡šç€ºãã ':.5f' = ':.3f'<nl>print(':.5f'.format(x)) ':.5f' = ':.3f'<nl>print(':.5f'.format(x))
æãç·ã°ã©ãã®ããå°ãèµ€ããã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='x', markerfacecolor='r') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='x', markerfacecolor='r')
ã»ãããããšã©ãŒãªãé
ãé€ã ã»ãã.discard(èŠçŽ ) ã»ãã.discard(èŠçŽ )
ããŒã¿ãã¬ãŒã ã®ããã«ã©ã ã¯äœå¹ŽãèŠã df['åA'].dt.year df['åA'].dt.year
決å®ä¿æ°ãç®åºãã sklearn.metrics.r2_score(æ£è§£ããŒã¿å, äºæž¬ããŒã¿å) sklearn.metrics.r2_score(ããŒã¿å, ããŒã¿å2)
numpyã䜿çšãã import numpy as np import numpy as np
ããŒã¿åã®åå€ã¯äœååºçŸããã確èªãã ds.value_counts() ds.value_counts()
ç©ã¿äžã暪æ£ã°ã©ãããããããã plt.barh(ã©ãã«å, ããŒã¿å, bottom=ããŒã¿åy, color='#800080') plt.barh(ã©ãã«å, ããŒã¿å, bottom=ããŒã¿åy, color='#800080')
æãç·ã°ã©ãã®è²ãããŒã¯ã¹ã©ãã°ã¬ãŒã«ã»ãããã plt.plot(ããŒã¿åx, ããŒã¿åy, color='darkslategray') plt.plot(ããŒã¿åx, ããŒã¿åy, color='darkslategray')
ããŒã¿ãã¬ãŒã ããåãäžã€ã®ã¿éžæãã df[['åA', 'åB', 'åC']] df[['åA', 'åB', 'åC']]
æãç·ã°ã©ãã®ã¯ãã¹ããŒã«ãŒã®ç·å¹
ãèšå®ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='x', markeredgewidth=2.5) plt.plot(ããŒã¿åx, ããŒã¿åy, marker='x', markeredgewidth=2.5)
ããŒã¿ãã¬ãŒã ã®éžæããã«ã©ã ãåã®äœã§äžžããŠãæŽæ°ã«ãã df[['åA', 'åB']].round(-1).astype(int) df[['åA', 'åB']].round(-1).astype(int)
ããŒã¿ãã¬ãŒã ã®éžæããã«ã©ã ã®NaNãåã®è¡ã®å€ã§åãã df[['åA', 'åB']].fillna(method='ffill') df[['åA', 'åB']].fillna(method='ffill')
æ£åžå³ãããã€ã€ãŠã£ããè²ã䜿ã£ãŠæç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, color='papayawhip') plt.scatter(ããŒã¿åx, ããŒã¿åy, color='papayawhip')
option: ããŒã«ãŒã®è²ãççã«ãã markerfacecolor = 'coral' markerfacecolor = 'coral'
æ£åžå³ã®ãã€ã³ãããŒã«ãŒã®ç·å¹
ãæå®ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='.', markeredgewidth=2.5) plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='.', markeredgewidth=2.5)
ããŒã¿ãã¬ãŒã ã®ããã«ã©ã ããªã¹ããšããŠéžæãã df['åA'].values.tolist() df['åA'].values.tolist()
ããŒã¿ãã¬ãŒã ã®NaNãåŸã®è¡ã®å€ã«æå®ãã df.fillna(method='bfill') df.fillna(method='bfill')
ãªããžã§ã¯ãã¯æŽæ°ã¯ã©ã¹ int = int<nl>isinstance(obj, int) int = int<nl>isinstance(obj, int)
ã€ãã©ãã«ãšé
åã«ã€ããŠæ£åžå³ãæç»ããŠããã€ã³ãããŒã«ãŒã®è²ãrgbã«èšå®ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='.', c=rgb) plt.plot(ããŒã¿åx, ããŒã¿åy, marker='.', c=rgb)
æååãã«ã³ãã䜿ã£ãŠåºåããåæãã æåå.split(',') æåå.split(',')
瞊æ£ã°ã©ãã®è²ãããŠããŒãã«ãŒã«ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='powderblue') plt.bar(ããŒã¿åx, ããŒã¿åy, color='powderblue')
é
åããã©ã³ãã ã«1åéžãã§ãªã¹ãã«ãã random.choice(é
å) random.choice(é
å)
option: ã³ãã³ãã»ãã¬ãŒã¿ã§çšãã sep = ':' sep = ':'
ååž°åæãKæè¿åæ³ãšããŠè¡ã model = sklearn.neighbors.KNeighborsRegressor(hidden_importances_) model = sklearn.neighbors.KNeighborsRegressor(n_neighbors=5)
äºå€æ°ã®æ倧å€ãèšç®ãã max(x, y) max(x, y)
ã²ã€ã³ãºããã«ãã¹ãã°ã©ã ã®è²ãæå®ãã plt.hist(ããŒã¿å, color='gainsboro') plt.hist(ããŒã¿å, color='gainsboro')
ãã¹ãã°ã©ã ã®è²ããªãªããã©ãã«å€æŽãã plt.hist(ããŒã¿å, color='olivedrab') plt.hist(ããŒã¿å, color='olivedrab')
æšæºå
¥åããå
¥åããã sys.stdin.readline() input()
2ã€ã®èŸæžãéå±€åãã collections.ChainMap(aDict, aDict2) collections.ChainMap(aDict, aDict2)
ãã€ãªã¬ããè²ã®çžŠæ£ã°ã©ããæç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='violet') plt.bar(ããŒã¿åx, ããŒã¿åy, color='violet')
ãã¹ãã°ã©ã ããã©ã¬ã¹ãã°ãªãŒã³è²ãçšããŠæç»ãã plt.hist(ããŒã¿å, color='forestgreen') plt.hist(ããŒã¿å, color='forestgreen')
倪åã«ãã f'\033[1m{x}\033[0m' f'\033[1m{x}\033[0m'
option: ããŒãããã«ã°ã©ãã®è²ãæå®ãã color = 'peachpuff' color = 'peachpuff'
æ°å€æå»ã®ããŒã¿åããã¿ã€ã ã¹ã¿ã³ãåã«å€æãã pd.to_datetime(ds, unit='s', utc=True) pd.to_datetime(ds, unit='s', utc=True)
ãªã¹ããšã€ãã©ãã«ã«ã€ããŠã®æ£åžå³ã倧ããnã§æç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, s=n) plt.scatter(ããŒã¿åx, ããŒã¿åy, s=n)
æŽæ°ã®4åã®äž æŽæ° / 4 æŽæ° / 4
è¡šããŒã¿ããåãäžã€éžæãã df[['åA']] df[['åA']]
option: ããŒã¯ã¹ã©ãã°ã¬ãŒè²ãçšãã color = 'darkslategray' color = 'darkslategray'
é»ããã€ã¢ã¢ã³ãããŒã«ãŒãæ£åžå³ã«äœ¿ã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='D', c='k') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='D', c='k')
ïŒã€ã®æååãåãã調ã¹ã æåå == æåå2 æåå == æåå2
option: â³ããŒã«ãŒãå ãã marker = '^' marker = '^'
ã¿ã€ã ã¹ã¿ã³ãããŒã¿ãäœåãç¥ã aDatetime.minute aDatetime.minute
ãµãŒã¢ã³è²ã®çžŠæ£ã°ã©ããæç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='salmon') plt.bar(ããŒã¿åx, ããŒã¿åy, color='salmon')
ããŒã¿åã®æšç§»ãéãç Žç·ãšããŠæã plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dashed', color='b') plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dashed', color='b')
option: è²ãé»ç·ã«èšå®ãã color = 'chartreuse' color = 'chartreuse'
瞊æ£ã°ã©ãã®è²ãã¬ããã«ããŒãã«ã«ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='rebeccapurple') plt.bar(ããŒã¿åx, ããŒã¿åy, color='rebeccapurple')
ããŒã¿ãã¬ãŒã ã衚瀺ãããšã衚瀺å¯èœãªåæ°ã®æ倧å€ãnã«æå®ãã pd.set_option('display.max_columns', n) pd.set_option('display.max_columns', n)
ã»ããã®è£éåãæ±ãã ã»ãã.difference(ã»ãã2) ã»ãã.difference(ã»ãã2)
option: ã€ã³ãã£ãŽè²ãçšãã color = 'indigo' color = 'indigo'
ããŒã¿ãã¬ãŒã ã®éžæããã«ã©ã ã1000ã®äœã§äžžãã df[['åA', 'åB']].round(-3) df[['åA', 'åB']].round(-3)
æãç·ã°ã©ããåéæã®ç Žç·ãçšããŠæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dashed', alpha=0.5) plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dashed', alpha=0.5)
JSONãã©ãŒãããã®ãã¡ã€ã«ãããŒã¹ãã with open('file.json') as f:<nl><tab>data = json.load(f) with open('file.json') as f:<nl><tab>data = json.load(f)
å€æ°åã¯ã¢ãžã¥ãŒã«ã調ã¹ã inspect.ismodule(èå¥å) inspect.ismodule(èå¥å)
ç·ã°ã©ãã®è²ãããŒã¯ã·ã¢ã°ãªãŒã³ã«èšå®ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='darkseagreen') plt.plot(ããŒã¿åx, ããŒã¿åy, color='darkseagreen')
ãªã¹ãã®æ«å°Ÿã«èŠçŽ ãå ãã ãªã¹ããããšããšã«ã¯äŒæ©(èŠçŽ ) ãªã¹ã.append(èŠçŽ )
æãç·ã°ã©ããããžã£ãŒãã«ãŒè²ãçšããŠæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='dodgerblue') plt.plot(ããŒã¿åx, ããŒã¿åy, color='dodgerblue')
æ°åã暪æ£ã°ã©ãã«ãã plt.barh(ã©ãã«å, ããŒã¿å) plt.barh(ã©ãã«å, ããŒã¿å)
ç·ã°ã©ãã®è²ãã¬ããã«ããŒãã«ã«èšå®ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='rebeccapurple') plt.plot(ããŒã¿åx, ããŒã¿åy, color='rebeccapurple')
option: ãã©ã³ãã®è²ãããŒã¯ãµãŒã¢ã³ã«èšå®ãã color = 'darksalmon' color = 'darksalmon'
暪ã«äžŠã¹ãŠé
åã床æ°ååžå³ã«ãã plt.hist([ããŒã¿å, ããŒã¿å], color=['b', 'r']) plt.hist([ããŒã¿å, ããŒã¿å], color=['b', 'r'])
option: 倧ããããŒã«ãŒãçšãã marker = 'X' marker = 'X'
åæ¹åãã¥ãŒã®äžã«æååã¯ååšãããã©ãã調ã¹ã æåå in 䞡端ãã¥ãŒ æåå in 䞡端ãã¥ãŒ
æå®ããã«ã©ã ã®æååãæªå
¥åå€ã«å€æãã df['åA'].replace(å€, np.nan) df['åA'].replace(å€, np.nan)
æãç·ããããã«ã©ãã«ãä»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, label='ã©ãã«') plt.plot(ããŒã¿åx, ããŒã¿åy, label='ã©ãã«')
ç·è²åãã f'\033[32m{x}\033[0m' f'\033[32m{x}\033[0m'
ããŒã¿ãã¬ãŒã ãšããŒã¿ã·ãªãŒãºãã€ãªã pd.concat([df, ds], axis=1) pd.concat([df, ds], axis=1)
éšåæååãæååã®éå§äœçœ®ããçµäºäœçœ®ãŸã§æ¢ã æåå.find(éšåæåå, éå§äœçœ®, çµäºäœçœ®) # èŠã€ãããªãå Žåã¯-1 æåå.find(éšåæåå, éå§äœçœ®, çµäºäœçœ®) # èŠã€ãããªãå Žåã¯-1
option: è²ã®éæ床ãæå®ãã alpha = 0.5 alpha = 0.5
ã«ã©ã ã®æ¬ æå€ãäžå€®å€ã§åãã df['åA'].fillna(df['åA'].median()) df['åA'].fillna(df['åA'].median())
æå®ããã«ã©ã ã®ããŒã»ã³ã¿ã€ã«ãæ±ãã df['åA'].quantile(ããŒã»ã³ã/100) df['åA'].quantile(ããŒã»ã³ã/100)
ããŒãã«ã«ãã¹ãã°ã©ã ã®è²ãèšå®ãã plt.hist(ããŒã¿å, color='purple') plt.hist(ããŒã¿å, color='purple')
ããŒã¿ãã¬ãŒã ã®æå100è¡ df.head(100) df.head(100)
option: ãã©ã³ãã®è²ãã·ãŒã°ãªãŒã³ã«ã»ãããã color ='seagreen' color = 'seagreen'
æ£åžå³ã®å°ãé»ããã plt.scatter(ããŒã¿åx, ããŒã¿åy, markerfacecolor='k') plt.scatter(ããŒã¿åx, ããŒã¿åy, markerfacecolor='k')
option: ãã©ã³ãã®è²ããã¹ãã£ããŒãºã«å€æŽãã color ='mistyrose' color = 'mistyrose'
ãã¡ã€ã«ãæåã³ãŒãtextãšããŠæžã蟌ã¿çšã«ãªãŒãã³ãã] open(filepath, mode='w', encoding=text) open(filepath, mode='w', encoding=text)
æãç·ã°ã©ãã®è²ããã£ã ã°ã¬ãŒã«å€æŽãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='dimgray') plt.plot(ããŒã¿åx, ããŒã¿åy, color='dimgrey')
ããŒã¿åéã®å¹³åïŒä¹èª€å·®ãèšç®ãã sklearn.metrics.mean_squared_error(ããŒã¿å, ããŒã¿å2) sklearn.metrics.mean_squared_error(ããŒã¿å, ããŒã¿å2)
option: è²ãããããã€ããã«ãŒã«å€æŽãã color ='midnightblue' color = 'midnightblue'
ããŒã¿ãã¬ãŒã ã®æå®ããã«ã©ã ã®NaNãçŽåŸã®å€ã§åãã df['åA'].fillna(method='bfill') df['åA'].fillna(method='bfill')
ã©ã³ã¿ã€ã ã®ååž°ã®æ倧åæ° sys.getrecursionlimit() sys.getrecursionlimit()
é
åãã䞡端ãã¥ãŒãæ°èŠçæãã collections.deque(é
å) collections.deque(é
å)
é»ãããããŒã«ãŒã§æ£åžå³ãæã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='x', c='k') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='x', c='k')
ãªã¹ããšãªã¹ãã«ã€ããŠã®æ£åžå³ã«é»ãå·Šäžè§ããŒã«ãŒãæã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='<', c='k') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='<', c='k')
ç Žç·ã«æãç·ã°ã©ãã®ç·ã®çš®é¡ãå€æŽãã plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dashed') plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dashed')
option: ãã©ã³ãã®è²ããªã¬ã³ãžã¬ããã«æå®ãã color = 'orangered' color = 'orangered'
ä»æ¥ãæ°Žææ¥ãå€å®ãã datetime.datetime.today().weekday() == 2 datetime.datetime.today().weekday() == 2
ãã¹ãã°ã©ã ãéç·è²ãçšããŠæç»ãã plt.hist(ããŒã¿å, color='turquoise') plt.hist(ããŒã¿å, color='turquoise')
æåã³ãŒãtextã§ãã¡ã€ã«ãã¹ãéã] text = 'utf-8'<nl>open(filepath, encoding=text) text = 'utf-8'<nl>open(filepath, encoding=text)
é
åãšãªã¹ãã®æ£åžå³ã«äžžããŒã«ãŒãæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='o') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='o')
ãã¹ãã°ã©ã ã®è²ããã¬ãããã«ã³ã€ãºã«å€æŽãã plt.hist(ããŒã¿å, color='paleturquoise') plt.hist(ããŒã¿å, color='paleturquoise')
æååã®å³ç«¯ããéšåæååãåãé€ã æåå.rstrip(éšåæåå) æåå.rstrip(éšåæåå)
ããŒã¿ãã¬ãŒã ã®éžæããåã®å€ãValueMapã§äžåºŠã«çœ®æãã df[['åA', 'åB']].replace(ValueMap) df[['åA', 'åB']].replace(ValueMap)
åºåã¹ããªãŒã ãæ¹è¡é€å€ããŠäžè¡ãã€èªã¿èŸŒã f.readline() f.readline()
æååãæåŸã®åºåãèšå·ã§åå²ããŠååãæ±ãã æåå.rpartition(ã»ãã¬ãŒã¿)[0] æåå.rpartition(ã»ãã¬ãŒã¿)[0]
ã°ã©ãã®ãã¶ã€ã³ããããã import seaborn as sns import seaborn as sns
ããŒã¿ãã¬ãŒã ã®äžã®ã«ã©ã ãçããéã«ãªãããã«nåã«ãã³åå²ãã pd.qcut(df[col], n) pd.qcut(df[col], n)
stringãã€ã³ããŒããã import string import string
æãç·ã°ã©ãã®è²ãããŒã«ã°ãªãŒã³ã«æå®ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='palegreen') plt.plot(ããŒã¿åx, ããŒã¿åy, color='palegreen')
æŽæ°ã8é²è¡šèšã«å€æãã oct(æŽæ°) oct(æŽæ°)
暪æ£ã°ã©ãããªãŒãããè²ã䜿ã£ãŠæç»ãã plt.barh(ããŒã¿åx, ããŒã¿åy, color='orchid') plt.barh(ããŒã¿åx, ããŒã¿åy, color='orchid')
ãã¯ãã«ã®èŠçŽ ããšã®ã¢ãããŒã«ç©ãæ±ãã np.multiply(aArray, aArray2) np.multiply(aArray, aArray2)
äºã€ã®ã«ãŠã³ã¿ã®ããããã«å«ãŸããèŠçŽ ãèšç®ãã aCounter & aCounter2 aCounter | aCounter2
ãªã¹ããšããŒã¿åã«ã€ããŠã®æ£åžå³ã«èµ€ãå·Šäžè§ããŒã«ãŒãæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='<', c='r') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='<', c='r')
è¡åã®åèšå€ãæ±ãã np.sum(aArray) np.sum(aArray)
ãšããã¯ç§ã®åããæ¥ä»ããŒã¿ã«ãã pd.to_datetime(df['åA'], unit='s', utc=True) pd.to_datetime(df['åA'], unit='s', utc=True)
ããŒã¿ãã¬ãŒã ã®éžæããã«ã©ã ã®äžã«ããæååã®æ°ãæ±ãã df[['åA', 'åB']].isin([value]).sum() df[['åA', 'åB']].isin([value]).sum()
æ£åžå³ãé»ããã€ã¢ã¢ã³ãããŒã«ãŒã§ãããããã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='D', c='k') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='D', c='k')
option: ãã©ã³ãã®è²ãã©ã€ãã°ã¬ãŒã«å€æŽãã color = 'lightgray' color = 'lightgrey'
æãç·ã°ã©ãã®è±åœ¢ããŒã«ãŒãé»ããã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='D', markerfacecolor='k') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='D', markerfacecolor='k')
æŽæ°ã®2é²æ°è¡šçŸ bin(æŽæ°) bin(æŽæ°)
ããã¹ããã¡ã€ã«ãã¡ã€ã«åãã filename = 'file.txt' # ãã¡ã€ã« name<nl>'.txt' = '.csv'<nl>filename.startswith('.txt') filename = 'file.txt' # ãã¡ã€ã« name<nl>'.txt' = '.csv'<nl>filename.startswith('.txt')
æå°ãšããŠããŒã¿åã®æãç·ã°ã©ããæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='*') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='*')
æŽæ°ã®åä¹ãèšç®ãã æŽæ° ** 4 æŽæ° ** 4
暪æ¹åã«äºã€ã®ããŒã¿ãã¬ãŒã ãããŒãžãã pd.merge(df, df2) pd.merge(df, df2)
æ°ããã¬ãŠã¹éçšååž°ã¢ãã«ãæ°èŠäœæãã model = sklearn.gaussian_process.GaussianProcessRegressor() model = sklearn.gaussian_process.GaussianProcessRegressor()
æ£åžå³ã«é»ãæããŒã«ãŒã䜿çšãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='*', c='k') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='*', c='k')
床æ°ååžå³ãäžéããäžéãŸã§ã®ç¯å²ã§æç»ãã plt.hist(ããŒã¿å, range=(start, end)) plt.hist(ããŒã¿å, range=(start, end))
æµ®åå°æ°ç¹æ°ã®åæ²ç·æ£æ¥ã®éæ°ãæ±ãã math.atanh(x) math.atanh(x)
æŽæ°ãnã§å²ãåãã æŽæ° % n == 0 æŽæ° % n == 0
æãç·ã°ã©ãã®è²ãã©ã€ãã°ãªãŒã³ã«æå®ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='lightgreen') plt.plot(ããŒã¿åx, ããŒã¿åy, color='lightseagreen')
æ¥ä»æå»ããŒã¿ã«næéåã足ã aDatetime + datetime.timedelta(hours=n) aDatetime + datetime.timedelta(hours=n)
ãšããã¯ç§ãæ¥ä»æå»ã«ãã datetime.datetime.fromtimestamp(timestamp) datetime.datetime.fromtimestamp(timestamp)
ãã©ãŒãããã§åãdatetime64åã«å€æãã pd.to_datetime(df['åA'], format='%Y-%m-%d') pd.to_datetime(df['åA'], format='%Y-%m-%d')
ããã³ãã³ãã©ã€ã³ãäžãããããªããåŠçãã if len(sys.argv) > 10:<nl><tab>print(sys.argv[1]) # å
·äœçãªåŠçã«ãã if len(sys.argv) > 1:<nl><tab>print(sys.argv[1]) # å
·äœçãªåŠçã«ãã
option: ããã£ã¢ã ãã€ãªã¬ããã¬ããã«ã°ã©ãã®è²ãèšå®ãã color ='mediumvioletred' color = 'mediumvioletred'
ã¯ã©ã¹åé¡ãKNNã䜿ã£ãŠãã model = sklearn.neighbors.KNeighborsClassifier(n_neighbors=5) model = sklearn.neighbors.KNeighborsClassifier(n_neighbors=5)
å°æ°ç¹æ°ã®ã¿ã³ãžã§ã³ãã®éæ° math.atanh(x) math.atan(x)
ã«ãŠã³ã¿ããæãé »åºãªé
ç®ã®ä»¶æ° aCounter.most_common()[1] aCounter.most_common()[1]
ããŒã¿ãã¬ãŒã ãã5è¡ã©ã³ãã ãµã³ããªã³ã°ãã df.sample(5) df.sample(5)
L1ãã«ã ã§ããŒã¿ãæ£ååãã "sklearn.preprocessing.Normalizer(norm=""l1"").fit_transform(""l1"")" "sklearn.preprocessing.Normalizer(norm=""l1"").fit_transform(ããŒã¿)"
ããŒã¿ãã¬ãŒã ã®æå®ããã«ã©ã ã®æååãNaNã«ãã df['åA'].replace(å€, np.nan) df['åA'].replace(å€, np.nan)
éè²ãçšããŠæ£åžå³ãæç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, color='blue') plt.scatter(ããŒã¿åx, ããŒã¿åy, color='blue')
æ¬æ¥ãISO8601圢åŒã®æååã«ãã datetime.datetime.today().isoformat() datetime.datetime.today().isoformat()
æ¥ä»æå»ããŒã¿ã¯æ¥ä»æå»ããŒã¿ããå
aDatetime > aDatetime2 aDatetime2 = aDatetime<nl>aDatetime < aDatetime2
èç«ã¬ã³ã¬è²ã§æšªæ£ã°ã©ããæç»ãã plt.barh(ããŒã¿åx, ããŒã¿åy, color='firebrick') plt.barh(ããŒã¿åx, ããŒã¿åy, color='firebrick')
èŠçŽ ã¯ã»ããã®ãããã確èªãã èŠçŽ in ã»ãã èŠçŽ in ã»ãã
éãäžç¹éç·ã§ã€ãã©ãã«ã®æšç§»ãæã plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dashbot', color='b') plt.plot(ããŒã¿åx, ããŒã¿åy, linestyle='dashbot', color='b')
æãç·ã°ã©ãããã€ãªã¬ããè²ãšããŠæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='violet') plt.plot(ããŒã¿åx, ããŒã¿åy, color='violet')
æ¥ä»ããŒã¿ã®ææ¥ã䜿ã aDate.weekday() aDate.weekday()
æ£åžå³ã«rgbã®åè§ããŒã«ãŒã䜿çšãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='s', c=rgb) plt.plot(ããŒã¿åx, ããŒã¿åy, marker='s', c=rgb)
暪æ£ã°ã©ããæç»ããŠããŒã®çžŠå¹
ã調æŽãã plt.barh(ã©ãã«å, ããŒã¿å, width=0.5) plt.barh(ã©ãã«å, ããŒã¿å, width=0.5)
ãªã¹ããšé
åã®æ£åžå³ã«èµ€ãäžžããŒã«ãŒãæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='o', c='r') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='o', c='r')
ããã¹ãæšå®ã§ååž°åæããã model = sklearn.linear_model.RANSACRegressor(random_state=0) model = sklearn.linear_model.RANSACRegressor(random_state=0)
option: ããããã€ããã«ãŒè²ãçšãã color ='midnightblue' color = 'midnightblue'
å®æ°ã®nä¹ã®å®æ°å°äœãç®åºãã pow(x, n, y) pow(x, n, y)
ãšããã¯ç§ã®ã«ã©ã ããPandasã®æ¥ä»åã«ãã pd.to_datetime(df['åA'], unit='s', utc=True) pd.to_datetime(df['åA'], unit='s', utc=True)
暪軞ã®ç®çã®å€ãå€æŽãã plt.xticks(ç®çãã®å€ãªã¹ã) plt.xticks(ç®çãã®å€ãªã¹ã)
option: ãã©ãã¯è²ãçšãã color = 'black' color = 'black'
ããŒã¿åãå¹³æ¹æ ¹å€æãã np.sqrt(ããŒã¿å) np.sqrt(ããŒã¿å)
option: è²ãããŒã¯ãªãŒãããã«èšå®ãã color = 'darkorchid' color = 'darkorchid'
ã°ã¬ãŒè²ã§æšªæ£ã°ã©ããæç»ãã plt.barh(ããŒã¿åx, ããŒã¿åy, color='grey') plt.barh(ããŒã¿åx, ããŒã¿åy, color='grey')
ããŒã¯ã¿ãŒã³ã€ãºè²ãšããŠæšªæ£ã°ã©ããæç»ãã plt.barh(ããŒã¿åx, ããŒã¿åy, color='darkturquoise') plt.barh(ããŒã¿åx, ããŒã¿åy, color='darkturquoise')
æé ã«ããåãããŒã«ããŠããŒã¿ãã¬ãŒã ã䞊ã¹ã df.sort_values(by='åA', ascending=True) df.sort_values(by='åA', ascending=True)
xãéè²ã§è¡šç€ºã§ããæååã«å€æãã f'\033[34m{x}\033[0m' f'\033[34m{x}\033[0m'
option: ãã©ã³ãã®è²ããã³ãã¯ãªãŒã ã«ãã color ='mintcream' color = 'mintcream'
ãªã¹ããšé
åã«ã€ããŠã®æ£åžå³ã«èµ€ãæããŒã«ãŒãæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='*', c='r') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='*', c='r')
æ£åžå³ãã°ãªãŒã³ã€ãšããŒè²ãçšããŠæç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, color='greenyellow') plt.scatter(ããŒã¿åx, ããŒã¿åy, color='greenyellow')
æ£åžå³ã®ã¯ãã¹å°ã®å€§ãããå€æŽãã plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='x', markersize=2.0) plt.scatter(ããŒã¿åx, ããŒã¿åy, marker='x', markersize=2.0)
å°æ°ç¹ä»¥äž'4'æ¡ãŸã§ã®æååã«ãã ':.4f'.format(x) ':.4f'.format(x)
æ£ã°ã©ããæ¿ãéè²ã§æç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='darkblue') plt.bar(ããŒã¿åx, ããŒã¿åy, color='darkblue')
åã®ååãåæãã æåå.values() df.columns
è¡åã®æå€§å€ np.max(aArray) np.max(aArray)
ããŒã¿ãã¬ãŒã ããéè€ãæ®ããéè€ãæ¶ã df.drop_duplicates(keep=False) df.drop_duplicates(keep=False)
ããŒã¿åãšãªã¹ãã«ã€ããŠã®æ£åžå³ã«rgbã®äžäžè§ããŒã«ãŒãæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='^', c=rgb) plt.plot(ããŒã¿åx, ããŒã¿åy, marker='^', c=rgb)
ã·ã¹ã«è²ãšããŠæ£åžå³ãæç»ãã plt.scatter(ããŒã¿åx, ããŒã¿åy, color='thistle') plt.scatter(ããŒã¿åx, ããŒã¿åy, color='thistle')
æ£åžå³ã«èµ€ãäžè§ããŒã«ãŒã䜿çšãã plt.plot(ããŒã¿åx, ããŒã¿åy, marker='^', c='r') plt.plot(ããŒã¿åx, ããŒã¿åy, marker='^', c='r')
ããã¹ããªç·åœ¢åé¡åšãäœã model = sklearn.linear_model.HuberClassifier() model = sklearn.linear_model.HuberClassifier()
option: ã©ãã³ããŒè²ã䜿çšãã color = 'lavender' color = 'lavender'
æ£ã°ã©ããæ·¡ãè¶è²è²ã§æç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='tan') plt.bar(ããŒã¿åx, ããŒã¿åy, color='tan')
ã«ããŽãªå¥ã«äžŠã¹ãŠããŒã¿ãã¬ãŒã ãç®±ã²ãå³ã«ãã sns.boxplot(x='ã«ããŽãªå', y='å', data=df) sns.boxplot(x='ã«ããŽãªå', y='å', data=df)
æ£ã°ã©ããããŒã¯ã¹ã¬ãŒããã«ãŒè²ãçšããŠæç»ãã plt.bar(ããŒã¿åx, ããŒã¿åy, color='darkslateblue') plt.bar(ããŒã¿åx, ããŒã¿åy, color='darkslateblue')
ãã¡ã€ã«ãã¹ãæåã³ãŒãtextãšããŠæžã蟌ã¿çšã«ãªãŒãã³ãã] open(filepath, mode='w', encoding=text) open(filepath, mode='w', encoding=text)
ãªã¹ããnåã«ãã³ãã³ã°ããnamesã®ã©ãã«ãã€ãã pd.cut(aList, n, labels=names) pd.cut(aList, n, labels=names)
xãšyãã¹ã©ãã·ã¥ã§åºåã£ãŠè¡šç€ºãã print(x, y, sep='/') print(x, y, sep='/')
èŸæžã®å
šãæ¶å»ãã èŸæž.clear() èŸæž.clear()
ãªãªãŒãè²ã§æšªæ£ã°ã©ããæç»ãã plt.barh(ããŒã¿åx, ããŒã¿åy, color='olive') plt.barh(ããŒã¿åx, ããŒã¿åy, color='olive')
ã«ããŽãªã§è²åãããŠãã«ç®±ã²ãå³ã§ããŒã¿ãã¬ãŒã ãå³ç€ºãã sns.boxplot(x='ã«ããŽãªå', y='å', hue='ã«ããŽãªå', data=df) sns.boxplot(x='ã«ããŽãªå', y='å', hue='ã«ããŽãªå', data=df)
æ°å€ããŒãåãããæååã«å€æãã str(n).zfill(æååå¹
) str(n).zfill(æååå¹
)
option: éãçšãã color = 'blue' color = 'blue'
ããŒãã«è²ãšããŠç·ã°ã©ããæç»ãã plt.plot(ããŒã¿åx, ããŒã¿åy, color='purple') plt.plot(ããŒã¿åx, ããŒã¿åy, color='purple')
暪軞ã®ç®çãæŽæ°åãã plt.xticks(np.arange(æå°å€, æ倧å€, éé)) plt.xticks(np.arange(æå°å€, æ倧å€, éé))
option: ã°ã©ãã®è²ãããŒãžãŒãã©ãŠã³ã«ã»ãããã color = 'rosybrown' color = 'rosybrown'
|