3.4-plot快速可视化 In [ ]:
import pandas as pd import numpy as npIn [ ]:
# dataframe.plot功能In [ ]:
# 3.4.2 单样本:生成随机数时间序列 --> 可视化数据样本 --> 模拟处理、绘制 df = np.random.randn(1000) dfOut[ ]:
array([ 1.98023731e+00, -7.29390598e-01, -1.21187714e+00, -9.44301451e-01, 8.43605087e-01, -6.60641773e-01, 2.24061891e-01, -1.13236584e+00, 2.93506989e-01, -8.07941265e-01, 2.33255706e+00, 1.25340531e+00, 2.97051898e-01, -9.94672315e-01, 1.08054783e+00, -1.85056505e+00, -5.04714753e-01, -2.42240478e-01, -4.15700069e-02, 3.03556383e-01, -3.19060298e-01, -4.35292253e-01, -4.22430053e-01, -4.20605755e-01, 7.44856249e-01, 5.17089768e-01, -1.64362176e-02, -1.11362307e+00, 1.04585866e+00, 6.78618728e-01, -4.72528678e-01, -1.14756472e+00, -2.09982446e-01, -1.56653472e+00, -3.42954301e-01, 8.35825719e-01, 3.14252304e-01, 1.17118523e+00, -5.03317241e-01, -8.72980502e-01, -1.80251486e-02, 3.65935098e-01, 3.28362643e-01, 7.80523622e-02, -3.62434274e-01, -3.75564591e-01, -2.22099003e+00, -1.20009513e+00, -5.96207263e-02, 1.60625250e+00, -9.46400324e-01, -4.89472826e-01, 1.42108488e+00, 5.13899981e-01, 1.41850282e+00, -3.28574997e-01, -1.26606568e+00, -6.52008281e-01, -1.89198691e+00, -9.42300391e-02, -1.33105183e+00, -9.14202331e-01, -6.64151205e-01, -5.84488147e-01, 2.36209799e-01, -2.07767852e-01, -1.87713760e+00, -4.31368812e-01, -9.12651356e-01, -2.10546118e-01, -1.11526303e+00, 1.51123532e+00, 5.29249831e-01, -5.02252166e-01, 4.56422165e-01, 8.91231236e-01, -1.24604605e+00, -1.31359964e+00, 3.61358202e-01, -2.19116861e-02, -6.47382591e-02, -7.90985262e-01, 5.29614563e-01, 7.35783192e-01, -3.97426024e-01, 9.11786206e-03, 1.62512658e-01, 9.67810513e-01, 1.44597328e-01, -2.19359819e-01, 8.64298842e-01, -3.87904381e-01, -1.22029983e+00, 3.47308022e-01, -1.04000097e-01, 1.06437731e+00, 2.19188699e+00, -1.30110393e+00, -7.77271245e-01, -1.04885683e-01, -1.12069659e+00, 6.10628898e-02, -3.84978966e-01, -9.00976341e-02, 8.92694500e-02, -3.66770922e-01, 4.52274306e-01, -1.68078355e+00, -7.45452585e-01, -1.13418214e+00, 3.23403024e-01, 3.06455988e-01, 9.09125963e-01, 4.98725412e-01, -8.56502012e-01, 5.57267548e-01, 1.75766165e+00, -7.42201139e-01, 5.07176021e-03, -1.48139902e-01, 7.60348564e-01, -6.02789554e-01, -6.26919702e-01, -2.29611431e+00, -1.03834006e+00, 2.94657584e-01, -1.25463749e-01, 3.16357624e-01, 1.27125652e-01, 2.31797184e+00, 2.19695085e+00, -1.22313975e+00, 1.03662717e+00, 1.95879894e+00, 7.44549542e-01, 8.64981807e-01, -6.39346742e-02, -2.55916243e-01, -7.67464899e-01, -1.12220893e+00, 8.52789453e-01, 1.14269889e+00, 1.50960704e+00, -3.88750600e-01, -8.42630315e-01, 1.43134287e+00, -4.29215798e-01, -8.94444225e-02, -8.92593956e-01, -1.86228243e+00, 6.09285524e-01, 1.82454061e-01, 1.20103651e-01, 5.62128025e-02, -1.60122657e+00, 3.99837397e-01, 1.31252182e-01, 3.26993504e-03, 4.32606066e-01, 3.70641506e-01, 2.22167253e+00, -7.19236090e-01, 2.21192238e-02, 1.11922942e+00, 1.61089220e+00, 3.60426572e-01, 1.59897647e+00, -1.60962344e-01, 1.41450650e+00, 6.41191147e-01, 1.40890319e+00, -1.05006979e-01, 4.02937237e-01, -1.34872211e+00, -9.95241233e-01, 1.42864986e+00, -7.33372375e-01, -1.51916847e-01, -5.19882311e-01, 1.59923162e+00, -5.79680444e-01, -6.20508180e-01, 5.35629110e-03, 1.29849995e+00, -3.69922164e-01, 3.96152150e-02, -2.18561252e-01, 5.39157162e-02, 2.50433915e-01, -1.44212189e+00, 1.29809426e+00, 6.16989181e-01, 1.29051023e+00, -1.62054298e+00, -7.03484096e-01, 2.33221449e-01, -3.26615264e-01, 8.53899364e-01, 6.92266147e-01, 3.76537241e-01, -4.91616386e-01, 2.60621952e-01, -1.05934557e+00, -1.03046905e+00, -9.32704594e-01, 1.01181428e+00, 6.32723800e-01, 1.04609947e+00, -4.31317837e-01, 1.46018730e+00, 9.97917653e-01, 6.89219901e-01, -1.02624160e+00, -3.93994348e-01, 8.51718322e-02, -1.83191824e-01, -8.18337861e-01, 9.16492635e-01, 2.21384836e+00, 4.04041159e-01, 5.81093416e-02, 1.01304732e+00, 1.35681972e-01, -1.03775707e+00, 6.05969955e-01, 1.45833886e+00, 1.03222741e+00, 3.21795229e-03, 1.14143537e+00, -2.91851816e-01, -4.45101581e-01, -3.48634664e-01, 1.46663533e-01, -8.94113563e-01, 2.33674958e-01, -2.21529447e-01, -4.34910940e-02, 1.27062000e-01, -1.14448525e+00, -1.85664406e+00, -9.94625465e-01, -1.44743966e+00, 1.33290024e+00, -8.97150877e-01, 1.43316285e+00, -1.31909579e+00, -2.25987003e+00, -1.54958398e-01, 4.94896583e-01, -1.46529115e+00, -4.52542803e-01, 6.63642324e-01, 7.30603194e-01, 4.66442584e-01, 8.00283091e-01, -9.15758648e-01, -7.30535044e-02, 1.55436360e+00, 1.65792531e+00, -7.98439942e-01, -8.03199812e-01, -3.96980554e-01, 1.32888945e-01, 1.01963985e+00, 1.86002487e+00, -1.81727054e+00, 1.02350373e+00, -1.97377569e-01, -9.28310099e-01, -9.16323250e-01, -1.57426346e+00, 9.85176952e-01, 6.55450837e-01, 6.10744233e-01, 2.03408349e-01, 1.83326497e+00, 6.94901939e-01, 1.33521496e+00, 4.05935588e-01, 1.42589698e-01, -2.62881405e-01, -6.09483049e-01, 2.64186072e-01, 9.38274781e-01, 1.20676909e+00, 3.98739825e-01, 1.06779235e-02, -7.48267397e-01, 5.28917794e-01, -1.20728272e+00, -1.05089796e+00, 3.60478372e-01, 4.18518388e-01, 4.35930915e-01, -2.75337471e-01, -2.17151934e-02, -2.93967845e-01, 1.58340658e-02, -1.95267689e+00, 2.48750526e-01, -1.87944113e+00, 1.54019016e+00, 1.32679805e+00, -1.41603088e+00, 1.05584331e+00, -5.21781528e-01, 5.20363897e-02, -2.60049054e-01, 1.05803768e+00, 2.07161425e+00, 1.13679705e+00, 4.63412221e-01, 9.95168446e-03, -1.16819450e+00, -5.01243344e-01, 1.34388594e-01, 4.09594440e-01, -1.35900221e-01, -7.89262680e-01, 2.08461512e+00, 7.71423619e-01, -4.84318532e-01, 2.23026172e-01, 1.99431568e+00, -1.34151716e-01, -5.37248708e-01, 2.07860397e-01, -6.62760568e-01, 3.84931491e-01, -3.03006542e-01, 3.18849717e-01, 2.96465246e-01, 1.04137609e+00, 8.72610898e-01, -6.76375267e-01, -7.93669640e-01, 5.65150168e-01, -3.83353045e-01, -1.92370706e-01, 1.66974433e+00, 6.43930648e-01, 4.39599411e-01, -6.36548406e-01, 8.70510022e-01, -7.64982706e-01, -1.01290111e+00, -1.77283726e+00, 8.19450342e-01, 1.07700299e+00, 1.47802968e+00, -4.29216263e-01, -1.39766705e+00, -1.33056255e-01, 9.23345472e-01, 6.93347522e-01, 1.80805855e-01, 1.64304312e-02, 8.29275108e-01, -8.25522772e-01, -3.19855535e+00, 3.72746174e-02, 1.73417882e+00, 1.37566494e+00, 4.31659802e-01, 1.34765418e+00, -1.02439100e+00, 5.83297537e-01, 5.87611686e-01, 5.83890387e-01, -1.79907797e+00, -1.30238506e+00, -8.22101220e-02, 6.92746667e-02, -3.25971046e-01, -4.70975877e-01, -2.29183670e-01, -9.30455397e-02, 1.30071204e+00, -3.44203048e-01, 2.73444435e-01, -1.64618332e+00, -1.29222012e+00, -2.40119485e+00, -2.74448003e-01, 2.49246031e-01, -5.00859204e-01, 1.13186358e+00, 1.87947199e+00, -6.89015735e-01, 7.14599884e-01, -1.97671974e-01, 1.01749195e+00, 1.15701585e+00, 6.47679971e-01, -5.32631873e-03, 1.26891637e-02, -4.41828321e-01, 1.10059577e+00, -6.84833069e-01, -5.48259355e-01, -1.13202090e+00, -1.57953321e-01, 1.49237576e-01, -1.02371982e+00, -1.25381648e+00, 1.65990675e+00, 9.57524638e-01, -1.52246252e+00, 1.87745546e-01, 1.84930298e+00, -4.98338057e-01, 1.12722638e+00, 6.10840094e-02, -4.42430217e-01, 2.23745660e+00, 3.73747547e-01, 1.10029922e+00, -1.07614880e+00, -9.20425343e-02, -7.74061111e-01, -6.70321895e-01, -5.75748877e-01, -7.65544503e-01, -3.21569611e-02, -8.18759873e-01, 9.91060287e-01, 2.38844311e-01, 8.37615711e-01, 5.19303446e-01, 6.99836673e-01, -8.93453620e-01, -1.50196980e+00, 6.96392807e-02, 3.27475104e-01, -1.66974021e-01, 1.15595960e+00, 1.25407116e-01, -9.29952606e-01, 1.84490535e-01, -2.37164198e-01, -2.84950369e-01, -1.94741956e+00, -5.37445301e-01, 3.22277279e-01, -1.82391052e+00, 7.45101203e-01, -6.33950692e-01, 1.13767260e+00, 3.35163506e-02, -1.13112033e+00, -1.21380810e+00, 1.37585016e+00, -8.77700012e-02, -7.45817787e-01, 5.45808992e-02, -1.00302257e+00, 7.66288293e-01, -4.94662908e-01, -2.32425903e+00, 3.99315919e-01, 1.07874631e+00, 1.85065907e+00, -4.15082529e-01, -2.12142024e+00, -1.38230883e+00, -6.26627563e-01, 1.00211517e-01, -6.50414183e-01, -9.12878987e-01, -2.42369230e+00, 6.04769967e-01, -3.57815769e-01, -4.20331838e-01, -4.36755355e-01, -5.14491765e-01, -4.59920709e-01, -6.99636796e-02, -9.75450605e-01, 1.35559667e+00, 9.29270846e-01, -6.38923665e-01, -4.26862854e-01, 8.49814534e-01, -1.01749398e+00, -2.64209192e-01, 6.41296977e-01, -1.15412611e+00, -7.54212862e-02, 7.84534877e-01, -9.01828766e-01, 4.10216662e-01, 1.19720617e+00, -7.73011721e-02, 9.56185609e-01, -3.59821515e-01, 3.28773905e-02, -7.31009186e-01, -9.02642476e-01, -1.47884115e+00, 1.60296972e+00, 1.84087164e-01, -1.24252150e+00, 5.73221567e-01, 2.03188551e-01, 8.44625646e-01, -1.01772430e-01, -7.36174611e-01, 6.36218493e-01, 2.89822401e+00, -1.39511220e+00, -4.76435399e-02, -7.41858856e-01, 4.73050262e-01, 9.89657415e-01, -2.23534436e-01, 1.28472802e-01, 1.34061790e-01, -5.72973595e-01, -6.48682343e-02, 1.62490962e-02, -1.60746446e+00, -1.58760402e+00, -2.83186103e-01, -2.26556480e+00, 3.93241398e-01, 1.17778072e+00, 2.55873271e-01, -1.22488375e+00, 8.97042166e-01, -1.87541851e-01, 9.35650863e-01, -1.01126046e+00, 1.63570205e-02, 1.00103847e+00, -4.05851969e-01, 1.25491179e+00, 1.19029558e+00, -5.70715523e-01, -2.04757390e-01, -1.30911423e+00, -2.00942017e-01, -1.99531893e+00, 1.75132412e+00, -3.59046552e-02, -2.60237332e-01, 3.46977809e-01, -7.96364040e-01, -5.68837597e-01, -1.21519244e+00, -8.15802585e-01, 1.30476015e+00, 6.43943044e-01, -8.88689648e-01, -8.36850667e-01, -1.06404297e+00, -1.63738857e+00, 4.00559837e-01, -1.28094946e-01, 1.48858468e+00, -1.27465832e+00, -6.69548832e-01, 5.53531906e-01, -8.55056623e-01, 1.32857094e+00, -1.25572439e+00, -1.90363217e-01, 7.43241335e-01, 6.24494136e-01, -6.71921235e-02, 1.10252548e-01, 9.72879872e-01, -1.99056581e-01, -1.01404332e+00, -2.84299051e-01, 1.10973527e-01, -4.86016723e-02, 4.07168034e-01, 8.42597387e-03, 1.39837233e+00, 1.07330223e+00, -3.75910799e-01, 6.54833574e-01, 8.03444711e-01, 4.35512900e-01, 8.07825323e-01, -3.01506699e-01, 7.65511247e-01, -1.38773418e+00, 1.13630081e+00, 1.33512242e+00, 2.79452703e-01, 1.90389846e-01, -1.68148822e-01, -6.00030682e-01, -1.01906518e+00, 7.06641359e-01, -1.28150781e+00, 2.65287600e-01, -4.97213406e-01, -8.30381103e-01, -9.45939215e-03, 8.42449040e-01, 5.75860992e-01, 4.91369124e-01, 1.50950034e+00, 8.67900246e-01, 9.54713833e-02, 8.96983126e-01, 2.13736344e-01, -1.27644740e+00, -5.77210242e-01, -1.52711635e+00, 2.47664890e-01, -1.40077657e+00, 5.91159001e-01, -7.40062896e-01, -1.18168363e-01, -5.01988961e-01, -9.60308406e-01, 3.62725143e-02, -2.68177198e-02, 4.83543299e-01, -3.58526402e-01, 6.92698277e-01, 3.33970982e-01, 4.57572294e-01, 5.36144020e-01, -3.75478386e-01, 8.61525320e-01, -7.35335172e-02, -2.20623178e+00, 9.13149407e-01, 8.60611527e-01, -5.38639450e-01, -1.52239748e+00, -1.53403773e+00, 1.30073282e+00, -1.74387004e+00, -2.82167846e-01, -8.34928502e-02, 5.04942334e-01, -2.22914886e+00, -2.31955091e-01, 1.26739246e-01, -1.52323767e-01, 1.10546465e+00, 4.56193689e-01, -4.77358859e-01, 8.45343416e-01, 7.86769649e-01, -1.17986089e+00, -1.99783872e-01, -4.36583397e-01, 5.80571185e-01, 5.46262184e-01, -1.07128082e+00, -1.03773979e+00, 1.45454182e-01, 1.07870097e+00, -5.50415901e-01, 1.99699535e+00, 2.29520821e-02, -1.26871128e+00, 1.13915251e+00, -1.07807355e+00, 7.25722765e-01, 1.37497626e+00, -1.08824067e+00, 1.75261993e-01, -8.61473707e-01, 1.78982605e-01, -6.69744221e-01, -6.46572663e-01, -4.35472721e-01, 1.04338080e-02, -1.32577045e+00, 1.60275681e+00, 8.46589325e-01, -2.89692706e-01, 4.33043976e-01, -3.05235539e-01, 5.35233483e-01, -2.86087379e-01, -5.79959148e-02, -2.00511183e+00, -1.24783945e+00, 5.50078154e-01, -4.60642264e-01, -1.03756084e+00, -9.32115658e-01, -8.49406070e-01, -1.13536287e+00, 1.59236876e-01, 7.48097750e-01, -7.44040315e-02, -2.00125918e+00, 1.15902733e-02, 2.84196920e-03, -1.04467500e+00, -9.71373167e-01, -3.54323374e-01, -7.56829268e-02, 3.91310864e-01, 1.88225102e-01, 3.67633582e-01, -7.86272427e-02, 1.73990909e+00, 7.47600368e-01, 1.05743057e+00, -1.06434002e+00, 6.36092910e-01, 1.00741354e+00, 4.51626628e-01, -1.10721527e+00, 4.14841668e-01, -7.77650516e-01, 9.51300212e-01, -2.60959737e-01, 5.02448913e-01, -6.94626947e-01, 1.10936084e+00, -4.97475636e-01, -4.41124315e-01, -3.78870149e-01, 2.38719560e-01, 1.58767495e-01, 1.39095443e-01, -4.86460479e-01, 4.45373893e-02, 2.72836302e+00, 6.37130299e-01, -1.15852794e+00, -2.44524943e-01, -9.25677150e-01, -8.62053970e-02, -6.23954455e-01, 7.48051441e-01, 6.18895521e-01, -2.97749197e-01, -1.63370209e+00, -8.54478825e-01, 9.71659088e-01, 5.01085199e-01, -1.13714556e+00, -1.90922863e-01, -1.10678774e+00, -1.06454977e-01, 1.77171249e-01, -7.95575707e-01, -1.13998647e+00, 5.09979459e-01, 8.81022791e-01, 3.20799418e-01, 5.66690135e-01, -1.33643998e+00, 5.89393367e-01, -2.28337122e+00, 3.55632160e-01, 4.23517314e-01, -1.74263030e+00, -1.31002901e-01, -2.79686369e-01, -2.08660885e+00, 2.36712541e-01, -1.48180840e-02, -6.59384871e-01, -2.29125418e+00, -1.57824645e+00, 8.21347516e-01, -4.90343565e-02, 1.57413318e-01, 3.77484976e-01, -7.74693321e-01, -1.19042949e+00, -8.73369101e-01, -9.38971687e-01, -6.83662203e-01, -1.86744893e-01, 1.55888452e+00, -7.99250088e-01, -2.34050077e+00, -3.69369611e-01, 1.38948328e+00, -5.59350402e-01, -3.13672723e-01, 6.15523785e-01, 6.60105717e-01, 7.54335531e-01, 2.81669511e-01, -1.74163698e+00, -1.56674142e-01, 8.94687332e-01, 1.68606125e+00, 1.82549837e-01, -1.28321866e+00, -6.94477353e-01, -3.17129289e-02, -7.62347282e-01, -3.74959966e-01, 6.99585427e-01, 1.40364051e+00, 1.35472457e+00, 1.10384841e-01, 1.87546332e-01, -1.18693035e-01, -3.25954809e-01, -1.45630428e+00, 8.71587208e-01, 5.89001817e-01, -1.26791035e+00, -1.40390226e+00, -1.25535605e+00, -8.25571484e-02, -1.55922022e+00, -1.57650162e+00, 2.06329433e-03, 1.08090507e+00, -3.88061895e-01, -5.19225711e-01, 4.18825309e-01, 5.35899854e-01, -5.42895430e-01, 4.03414165e-01, -7.73296988e-01, 1.28807942e+00, 1.12809466e+00, -8.05824033e-01, 1.41178968e-01, -1.21947146e+00, 7.76484486e-01, 1.58405500e+00, -1.79341595e+00, -7.10592737e-02, 1.02263793e+00, 1.46480170e+00, 5.97755502e-01, -5.72605739e-01, 6.49855243e-01, 2.02061424e-01, -3.50829077e-01, -9.51151069e-02, 1.02745859e+00, 9.63182987e-01, -2.97281242e+00, 3.72537399e-01, 2.91984879e-01, -1.29909186e-01, 1.87540759e+00, 2.19685058e+00, -5.21279364e-01, 1.27749019e+00, 7.56587090e-01, 2.49696175e-01, -5.60834259e-01, -2.04470346e-01, -1.12060820e+00, -7.61610391e-01, 3.66816005e-01, 9.21946735e-01, -5.12808796e-01, 5.38636064e-01, -2.51775643e-01, -2.44525918e+00, 1.34554576e+00, 9.18212510e-01, 4.88047184e-01, -1.53869418e-01, -5.78136453e-01, -9.94020084e-01, -5.71868289e-02, 1.91419741e-01, -1.88138918e-01, 8.25927810e-01, 8.26632911e-02, 5.19735238e-01, 1.97712235e+00, 2.99895522e-01, 3.95329591e-01, -3.25634950e-01, 2.47202575e-01, -1.69835178e-01, 1.24033328e-01, -1.61591981e+00, -7.28642245e-01, 8.73660668e-03, -2.20195581e+00, -8.00379222e-02, -1.15543047e+00, 1.70965825e+00, -7.83688016e-01, 1.18236530e+00, 3.17412372e-02, 1.26303480e+00, 4.15565328e-01, -1.10274873e+00, 1.48421222e+00, 3.56578140e-01, 1.72833077e+00, -6.66565595e-01, -7.37405803e-01, -1.52431458e+00, 1.29924130e+00, 8.87079385e-01, 2.60568470e-01, 1.79793941e-01, 1.46838609e+00, 1.46438804e+00, -1.79247058e+00, -3.48880353e-01, -4.15002305e-03, -1.03171850e+00, 2.91636717e-01, -1.90745068e+00, 7.45420590e-01, 2.04729967e+00, 6.50453437e-01, 1.82874326e+00, -6.92057690e-01, 3.59589574e-01, -1.19127096e+00, 2.93786300e-01, 2.82529493e-01, 3.99095456e-01, -3.01668263e-01, 8.55716096e-01, -7.36371474e-01, -1.49424280e+00, -5.72105104e-01, 1.57993397e+00, 8.41332320e-01, 3.91845848e-01, -7.81317740e-01, 1.37456890e+00, 6.72021358e-01, -1.66509853e+00, 1.32916912e-01, 3.53776502e-01, 8.21282544e-01, 6.83509026e-01, -1.40955990e+00, 1.59362823e+00, 1.10935599e+00, 8.22945999e-01, 4.01362612e-01, 1.45198968e+00, -1.76974866e-01, -8.60610559e-01, 1.51908797e+00, 5.38304351e-01, -1.60074606e+00, 7.48355979e-01, 7.85493799e-01, 1.53054743e-01, 1.23870115e-01, 4.76671517e-02, 2.58486543e-01, -6.83672882e-01, -1.99656371e+00, -1.19383592e+00, -1.39868555e+00, -3.73121481e-01, 3.26015391e+00, 3.21637043e-01, -3.64609318e-01, 1.86599158e-01, -3.68188627e-01, 5.72786569e-01, -5.51944039e-01, -3.16390206e-01, 1.40969955e+00, 2.02417917e-01, -7.47987235e-01, -8.19101212e-02, 1.96718171e+00, 4.46146841e-01, 1.52865477e+00, -1.22679442e+00, -5.35761425e-01, 3.80404013e-01, -2.23831449e-02, -1.57959273e+00, -1.04313714e+00, 6.23255952e-01, 3.68980246e-02, -2.46623014e+00, -1.72508821e+00, 5.92714919e-02, 1.94651156e-01, 2.91403105e-01, -1.06622024e+00, 1.34673196e+00, -9.57300833e-01, -7.66648650e-01, 3.40900711e-01, 6.87646649e-01, 1.29554671e+00, 1.18354858e-01, 1.41877761e+00, -2.38609762e-01, -3.93554916e-01])In [ ]:
df = pd.DataFrame(df,index=pd.date_range("20200101",periods=1000)) df.plot()Out[ ]:
<Axes: >In [ ]:
df['cumsum'] = df.cumsum() dfOut[ ]:
0 | cumsum | |
---|---|---|
2020-01-01 | 1.980237 | 1.980237 |
2020-01-02 | -0.729391 | 1.250847 |
2020-01-03 | -1.211877 | 0.038970 |
2020-01-04 | -0.944301 | -0.905332 |
2020-01-05 | 0.843605 | -0.061727 |
... | ... | ... |
2022-09-22 | 1.295547 | -21.183233 |
2022-09-23 | 0.118355 | -21.064879 |
2022-09-24 | 1.418778 | -19.646101 |
2022-09-25 | -0.238610 | -19.884711 |
2022-09-26 | -0.393555 | -20.278266 |
1000 rows × 2 columns
In [ ]:df['cumsum'].plot()Out[ ]:
<Axes: >In [ ]:
# 3.4.3 多样本 pd.DataFrame(np.random.randn(1000)).hist() # 直方图Out[ ]:
array([[<Axes: title={'center': '0'}>]], dtype=object)In [ ]:
df2 = pd.DataFrame(np.random.randn(1000,4), columns=['A','B','C','D'],index=pd.date_range('20200101',periods=1000))In [ ]:
df2Out[ ]:
A | B | C | D | |
---|---|---|---|---|
2020-01-01 | -0.316267 | -0.064917 | 0.135941 | -1.683531 |
2020-01-02 | -1.775707 | 1.260687 | -0.112083 | -0.946609 |
2020-01-03 | 0.271756 | -1.231808 | 0.311042 | 0.299439 |
2020-01-04 | -0.693046 | -0.260170 | -0.507994 | -1.618444 |
2020-01-05 | 1.063937 | 1.523653 | -1.130773 | -0.760272 |
... | ... | ... | ... | ... |
2022-09-22 | -0.134058 | 0.651518 | 1.246924 | 1.916938 |
2022-09-23 | -1.451481 | 0.076728 | -1.271193 | 0.510011 |
2022-09-24 | -0.692761 | 0.834845 | -0.819874 | 0.154790 |
2022-09-25 | 1.500856 | -0.364554 | -0.896864 | 0.717778 |
2022-09-26 | -0.563136 | 0.625665 | 0.168741 | -1.570240 |
1000 rows × 4 columns
In [ ]:df2.hist()Out[ ]:
array([[<Axes: title={'center': 'A'}>, <Axes: title={'center': 'B'}>], [<Axes: title={'center': 'C'}>, <Axes: title={'center': 'D'}>]], dtype=object)In [ ]:
df2.plot()Out[ ]:
<Axes: >In [ ]:
df2sum = df2.cumsum() df2sum.plot()Out[ ]:
<Axes: >In [ ]: 标签:02,plot,00,01,03,3.4,可视化,2022,2020 From: https://www.cnblogs.com/mlzxdzl/p/17772472.html