Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 419d226

Browse files
numpy
numpy
1 parent 09e83ed commit 419d226

File tree

1 file changed

+196
-0
lines changed

1 file changed

+196
-0
lines changed

‎dataAnalysis/Magical-numpy/numpy基础.ipynb

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,202 @@
413413
"print(np.argmin(a, axis=1))"
414414
]
415415
},
416+
{
417+
"cell_type": "code",
418+
"execution_count": 44,
419+
"metadata": {},
420+
"outputs": [
421+
{
422+
"name": "stdout",
423+
"output_type": "stream",
424+
"text": [
425+
"mean : 3.6666666666666665\n"
426+
]
427+
}
428+
],
429+
"source": [
430+
"print(\"mean : {}\".format(np.mean(a))) # 求矩阵均值"
431+
]
432+
},
433+
{
434+
"cell_type": "code",
435+
"execution_count": 45,
436+
"metadata": {},
437+
"outputs": [
438+
{
439+
"name": "stdout",
440+
"output_type": "stream",
441+
"text": [
442+
"mean : [1. 5.5 4.5]\n"
443+
]
444+
}
445+
],
446+
"source": [
447+
"print(\"mean : {}\".format(np.mean(a, axis=0)))"
448+
]
449+
},
450+
{
451+
"cell_type": "code",
452+
"execution_count": 46,
453+
"metadata": {},
454+
"outputs": [
455+
{
456+
"name": "stdout",
457+
"output_type": "stream",
458+
"text": [
459+
"3.5\n"
460+
]
461+
}
462+
],
463+
"source": [
464+
"print(np.median(a))# 求矩阵中数据的中位数"
465+
]
466+
},
467+
{
468+
"cell_type": "markdown",
469+
"metadata": {},
470+
"source": [
471+
"# 3. 获取数据"
472+
]
473+
},
474+
{
475+
"cell_type": "code",
476+
"execution_count": 47,
477+
"metadata": {},
478+
"outputs": [],
479+
"source": [
480+
"import numpy as np"
481+
]
482+
},
483+
{
484+
"cell_type": "code",
485+
"execution_count": 48,
486+
"metadata": {},
487+
"outputs": [
488+
{
489+
"name": "stdout",
490+
"output_type": "stream",
491+
"text": [
492+
"[1 2 3 4 5 6]\n",
493+
"[[1 2 3]\n",
494+
" [4 5 6]]\n"
495+
]
496+
}
497+
],
498+
"source": [
499+
"a = np.arange(1,7)\n",
500+
"b = a.reshape((2,3))\n",
501+
"print(a)\n",
502+
"print(b)"
503+
]
504+
},
505+
{
506+
"cell_type": "code",
507+
"execution_count": 49,
508+
"metadata": {},
509+
"outputs": [
510+
{
511+
"data": {
512+
"text/plain": [
513+
"4"
514+
]
515+
},
516+
"execution_count": 49,
517+
"metadata": {},
518+
"output_type": "execute_result"
519+
}
520+
],
521+
"source": [
522+
"a[3]"
523+
]
524+
},
525+
{
526+
"cell_type": "code",
527+
"execution_count": 50,
528+
"metadata": {},
529+
"outputs": [
530+
{
531+
"data": {
532+
"text/plain": [
533+
"array([1, 2, 3])"
534+
]
535+
},
536+
"execution_count": 50,
537+
"metadata": {},
538+
"output_type": "execute_result"
539+
}
540+
],
541+
"source": [
542+
"b[0]"
543+
]
544+
},
545+
{
546+
"cell_type": "code",
547+
"execution_count": 51,
548+
"metadata": {},
549+
"outputs": [
550+
{
551+
"data": {
552+
"text/plain": [
553+
"2"
554+
]
555+
},
556+
"execution_count": 51,
557+
"metadata": {},
558+
"output_type": "execute_result"
559+
}
560+
],
561+
"source": [
562+
"b[0][1]"
563+
]
564+
},
565+
{
566+
"cell_type": "code",
567+
"execution_count": 52,
568+
"metadata": {},
569+
"outputs": [
570+
{
571+
"data": {
572+
"text/plain": [
573+
"array([1, 2, 3])"
574+
]
575+
},
576+
"execution_count": 52,
577+
"metadata": {},
578+
"output_type": "execute_result"
579+
}
580+
],
581+
"source": [
582+
"a[0:3]"
583+
]
584+
},
585+
{
586+
"cell_type": "code",
587+
"execution_count": 53,
588+
"metadata": {},
589+
"outputs": [
590+
{
591+
"data": {
592+
"text/plain": [
593+
"array([4, 5])"
594+
]
595+
},
596+
"execution_count": 53,
597+
"metadata": {},
598+
"output_type": "execute_result"
599+
}
600+
],
601+
"source": [
602+
"b[1,0:2]"
603+
]
604+
},
605+
{
606+
"cell_type": "markdown",
607+
"metadata": {},
608+
"source": [
609+
"# 4. 数组合并"
610+
]
611+
},
416612
{
417613
"cell_type": "code",
418614
"execution_count": null,

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /