seaborn not plotting scatterplot as expected - python-3.x
I have written the following simple code :
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
advertising = pd.read_csv("tv-marketing.csv")
sns.pairplot(advertising, x_vars=[
'TV'], y_vars='Sales', height=7, aspect=0.7)
The following is the .csv file that is being used here -
TV,Sales
230.1,22.1
44.5,10.4
17.2,9.3
151.5,18.5
180.8,12.9
8.7,7.2
57.5,11.8
120.2,13.2
8.6,4.8
199.8,10.6
66.1,8.6
214.7,17.4
23.8,9.2
97.5,9.7
204.1,19
195.4,22.4
67.8,12.5
281.4,24.4
69.2,11.3
147.3,14.6
218.4,18
237.4,12.5
13.2,5.6
228.3,15.5
62.3,9.7
262.9,12
142.9,15
240.1,15.9
248.8,18.9
70.6,10.5
292.9,21.4
112.9,11.9
97.2,9.6
265.6,17.4
95.7,9.5
290.7,12.8
266.9,25.4
74.7,14.7
43.1,10.1
228,21.5
202.5,16.6
177,17.1
293.6,20.7
206.9,12.9
25.1,8.5
175.1,14.9
89.7,10.6
239.9,23.2
227.2,14.8
66.9,9.7
199.8,11.4
100.4,10.7
216.4,22.6
182.6,21.2
262.7,20.2
198.9,23.7
7.3,5.5
136.2,13.2
210.8,23.8
210.7,18.4
53.5,8.1
261.3,24.2
239.3,15.7
102.7,14
131.1,18
69,9.3
31.5,9.5
139.3,13.4
237.4,18.9
216.8,22.3
199.1,18.3
109.8,12.4
26.8,8.8
129.4,11
213.4,17
16.9,8.7
27.5,6.9
120.5,14.2
5.4,5.3
116,11
76.4,11.8
239.8,12.3
75.3,11.3
68.4,13.6
213.5,21.7
193.2,15.2
76.3,12
110.7,16
88.3,12.9
109.8,16.7
134.3,11.2
28.6,7.3
217.7,19.4
250.9,22.2
107.4,11.5
163.3,16.9
197.6,11.7
184.9,15.5
289.7,25.4
135.2,17.2
222.4,11.7
296.4,23.8
280.2,14.8
187.9,14.7
238.2,20.7
137.9,19.2
25,7.2
90.4,8.7
13.1,5.3
255.4,19.8
225.8,13.4
241.7,21.8
175.7,14.1
209.6,15.9
78.2,14.6
75.1,12.6
139.2,12.2
76.4,9.4
125.7,15.9
19.4,6.6
141.3,15.5
18.8,7
224,11.6
123.1,15.2
229.5,19.7
87.2,10.6
7.8,6.6
80.2,8.8
220.3,24.7
59.6,9.7
0.7,1.6
265.2,12.7
8.4,5.7
219.8,19.6
36.9,10.8
48.3,11.6
25.6,9.5
273.7,20.8
43,9.6
184.9,20.7
73.4,10.9
193.7,19.2
220.5,20.1
104.6,10.4
96.2,11.4
140.3,10.3
240.1,13.2
243.2,25.4
38,10.9
44.7,10.1
280.7,16.1
121,11.6
197.6,16.6
171.3,19
187.8,15.6
4.1,3.2
93.9,15.3
149.8,10.1
11.7,7.3
131.7,12.9
172.5,14.4
85.7,13.3
188.4,14.9
163.5,18
117.2,11.9
234.5,11.9
17.9,8
206.8,12.2
215.4,17.1
284.3,15
50,8.4
164.5,14.5
19.6,7.6
168.4,11.7
222.4,11.5
276.9,27
248.4,20.2
170.2,11.7
276.7,11.8
165.6,12.6
156.6,10.5
218.5,12.2
56.2,8.7
287.6,26.2
253.8,17.6
205,22.6
139.5,10.3
191.1,17.3
286,15.9
18.7,6.7
39.5,10.8
75.5,9.9
17.2,5.9
166.8,19.6
149.7,17.3
38.2,7.6
94.2,9.7
177,12.8
283.6,25.5
232.1,13.4
This is the output graph that I am getting (Running it from vscode->Run Current File
in Interactive Window
vscode output
But the expected output form the example that I took should be like this :
expected output 1
expected output 2
**Neither do I see the scatterplot, also the scaling is different.**
I believe the code you are looking for is the following:
sns.scatterplot(x='TV', y='Sales', data=advertising)
If you want to use pairplot then you can use:
sns.pairplot(advertising, height=7, aspect=0.7)
or:
sns.pairplot(sample_data, x_vars=['TV'], y_vars=['Sales'], height=7, aspect=0.7, kind='scatter', diag_kind=None)
Related
Why is the use of "color" considered an error?
I have been running a manim code, and it specifies: "TypeError: Mobject.getattr..getter() got an unexpected keyword argument 'color'" This is the code I am trying to run: from manim import * class Function(Scene): def construct(self): ax=Axes(x_range=[-5,5,0.5], y_range=[-3,3,0.5], x_axis_config={"numbers_to_include": np.arange(-5,5,1)}, y_axis_config={"numbers_to_include": [1]}) #ax_labels=ax.get_axis_labels(x_label="Time (t)", y_label=Tex(r"y=sin(x)")) ax_labels=ax.get_axis_labels() sin_graph=ax.get_graph(lambda x: np.sin(2*x), color=BLUE) cos_graph = ax.get_graph(lambda x: np.cos(2*x), color=RED_B) sin_label=ax.get_graph_label(sin_graph, label="\\sin(x)", x_val=-4.5, direction=UP*4) cos_label=ax.get_graph_label(cos_graph, label="\\cos(x)", x_val=4.5, direction=DOWN*2) ax_group=VGroup(ax, ax_labels) #labels=VGroup(sin_label, cos_label) self.play(Create(ax_group), run_time=6) self.wait() self.play(Write(sin_label)) self.play(Create(sin_graph), run_time=2) self.wait() self.play(Create(cos_graph), run_time=2) self.play(Write(cos_label)) self.wait() I was expecting an animation of a sin graph, but it didn't work as specified above.
The error message from get_graph is unfortunately somewhat unhelpful. Practically, get_graph has been renamed to plot a while ago. See the docuementation: https://docs.manim.community/en/stable/reference/manim.mobject.graphing.coordinate_systems.CoordinateSystem.html?highlight=plot#manim.mobject.graphing.coordinate_systems.CoordinateSystem.plot
trouble with transpose in pd.read_csv
I have a data in a CSV file structured like this Installation Manufacturing Sales & Distribution Project Development Other 43,934 24,916 11,744 - 12,908 52,503 24,064 17,722 - 5,948 57,177 29,742 16,005 7,988 8,105 69,658 29,851 19,771 12,169 11,248 97,031 32,490 20,185 15,112 8,989 119,931 30,282 24,377 22,452 11,816 137,133 38,121 32,147 34,400 18,274 154,175 40,434 39,387 34,227 18,111 I want to skip the header and transpose the list like this 43934 52503 57177 69658 97031 119931 137133 154175 24916 24064 29742 29851 32490 30282 38121 40434 11744 17722 16005 19771 20185 24377 32147 39387 0 0 7988 12169 15112 22452 34400 34227 12908 5948 8105 11248 8989 11816 18274 18111 Here is my code import pandas as pd import csv FileName = "C:/Users/kesid/Documents/Pthon/Pthon.csv" data = pd.read_csv(FileName, header= None) data = list(map(list, zip(*data))) print(data) I am getting the error "TypeError: zip argument #1 must support iteration". Any help much appreciated.
You can read_csv in "normal" mode: df = pd.read_csv('input.csv') (colum names will be dropper later). Start processing from replacing NaN with 0: df.fillna(0, inplace=True) Then use either df.values.T or df.values.T.tolist(), whatever better suits your needs.
You should use skiprows=[0] to skip reading the first row and use .T to transpose df = pd.read_csv(filename, skiprows=[0], header=None).T
plot with hist function get wrong normalized probability density figure
I want drow a simple hist plot, with density=True, the data saved in the data.txt file, I put here: -3.159589616094560238e-02 -2.238517986981702901e-02 3.685513259832978727e-02 5.551115123125782702e-17 3.855829197377269590e-02 1.106747485805819609e-01 -1.343976685751569478e-01 4.594910529316376113e-03 4.908490856818659154e-04 3.419692699076753994e-02 -1.000969353410680052e-02 -3.022899285774027778e-02 -5.537409517542163373e-02 -4.602923607484266100e-02 3.284859133476397686e-02 -1.023686626680164746e-02 -3.664415656649880337e-02 8.171815787883440763e-02 2.999203027116759124e-02 5.004522795043858663e-02 7.388383006436807787e-02 6.113278573286806683e-02 6.386857025829173473e-02 3.591723008598152189e-02 6.549840356253561202e-02 1.253856364955455160e-02 6.041119437265624059e-02 6.908608718235104140e-02 1.134341604638248180e-01 -1.576914025344122727e-02 -2.417229901971842954e-02 -3.899153022868465102e-02 4.689096941761000670e-02 5.841198683607556896e-02 8.641413395100966399e-02 5.642541143884205468e-02 4.930903227540417433e-03 1.942745077277890919e-02 2.158310326121676281e-02 1.049712334090066590e-02 1.754053058915017171e-02 -2.353744351610204122e-02 -8.208313574505410326e-03 5.744397964275682611e-02 -1.211723809639734806e-01 -8.992113883794172757e-02 1.061556222415527273e-02 -2.920395846191836675e-02 1.037069716181004964e-03 -3.161371576086063895e-02 -3.612043404641407385e-02 -1.809334659086286878e-02 3.662870373600723983e-02 1.391056336430290807e-02 -1.172024701805174929e-01 3.251886867868275521e-02 2.396867235334465551e-02 3.837332827102124533e-02 6.056630689588365923e-02 8.321671975043376523e-02 1.115621200150082593e-01 8.420054612809740879e-02 5.823374107493473062e-02 7.729794103241893755e-02 2.477495629227444152e-02 2.972088991663957014e-02 3.742060783581174777e-02 -1.110223024625156540e-16 2.587337514429000063e-02 1.527836714091357351e-02 1.958896955617406288e-02 -1.832210450473931163e-02 -1.926657560263266011e-02 2.339325805152586701e-02 -6.324903516012525539e-02 -6.690299051450193657e-02 -2.482072685296415893e-02 3.064499196744452370e-02 3.355998562941886476e-02 1.788746275401903452e-02 4.613919286422546451e-03 -8.927918985562194321e-03 1.028462556431128383e-02 5.532095657291985491e-02 6.604320581321337924e-02 3.669973111374175145e-02 2.277477855616832914e-02 4.808227903197481723e-02 4.832747444828244809e-02 7.656143177495855490e-03 1.245515608493746873e-02 2.349500690106676171e-02 4.072972204376856808e-03 2.516504860752621919e-02 2.003738740895273651e-02 -2.613223707890222069e-02 4.011136596889314232e-03 2.548231927644559192e-02 1.330938824527588826e-02 2.404439993147697296e-02 6.907130907663830421e-03 6.979484635157226502e-03 -3.290848338052448918e-02 -1.755191743006401239e-02 -3.366674089662069491e-04 5.945578987875954624e-05 -1.632427050508156174e-02 -8.658771138098070308e-02 -4.820886804917889901e-02 -8.546677486103770871e-03 -6.925724668856880761e-03 -9.925127350824403116e-04 -2.449622387186950467e-02 3.123051142945909575e-02 5.795788098893345230e-02 3.605543122998344785e-02 3.302943330800275912e-02 7.059531249141720588e-02 5.853930993753908574e-02 3.905874422983779404e-02 4.843263815672965711e-02 4.147627035435175191e-02 8.400424535113787394e-02 9.844201764532001242e-02 9.294548499676424935e-02 6.497483032833101246e-02 1.144645348202695256e-01 2.999608390738961461e-02 3.085053739416804275e-02 2.276726259836320265e-02 0.000000000000000000e+00 -2.510456168410146738e-02 2.116637291906409146e-02 -3.321700185738685196e-02 3.982853772878908183e-03 1.363191485535983349e-02 1.564968650026804520e-02 1.478997225428510531e-02 -3.131685025064945282e-03 -3.806954212751323396e-02 -8.159214863622976655e-03 -7.186257889362090978e-02 -9.500427775385178464e-04 -3.395150378118699797e-02 7.110268582201983989e-03 -2.162228010763439512e-02 -5.384418762160989025e-02 -7.415379224082696563e-03 8.122245670091066128e-03 -2.878373343427720332e-02 -4.544898403509023410e-04 2.231065952279343012e-02 5.253618584763958266e-02 7.567731789121345809e-03 1.043630861213364069e-02 9.691633727966997292e-03 -2.829666135637745605e-03 -1.504340107365054191e-03 1.140727886561562765e-02 1.089115013359434614e-02 1.044992233561446715e-02 9.693261114407991652e-03 -5.238694978638769317e-02 -2.457125444725005714e-02 1.077886426445628931e-03 -4.871118148953068605e-02 -6.495809610443054050e-02 -3.267035029465242824e-02 -2.674999216286094716e-02 -3.357327749680671936e-02 -8.093857036171048236e-03 4.214960036162579415e-02 8.643719482737677318e-03 -5.065308732882500831e-02 -1.275187831141166850e-02 4.968104321639105203e-03 3.038550497837352871e-02 1.292634450475451113e-01 9.960248360301909853e-02 9.926289065772253561e-02 1.218752249462111137e-01 6.588591178993197239e-02 5.093094629578931443e-02 4.116752669646578378e-02 4.345115715519703992e-02 1.576461619520656832e-02 4.396757184635238791e-03 -4.521077126215883313e-03 1.461648603205449592e-02 4.788312032257657780e-02 2.755872630307917848e-02 6.861615560310868611e-03 2.549852881708733476e-02 -5.168013319340802880e-03 -1.887369212351849845e-02 -2.441207169456885429e-02 -3.320040226240705827e-02 -6.425229768996637558e-02 -3.663909065452941594e-02 -3.102327088584733161e-02 -4.127076305809684875e-02 -5.684992379213882341e-03 2.906307859990353570e-03 -3.900653434877507375e-02 1.512074322144520977e-01 -2.515933869270309264e-02 -6.296389906200300368e-02 -9.272701261054544508e-02 -4.790753677805792421e-03 4.813151476583615862e-02 7.650062035746391098e-02 3.302890273769037988e-04 5.380904266441388639e-03 -2.202552482575392823e-03 -2.787433399598707173e-04 3.384160594702279035e-02 1.300796256094960412e-02 -1.160214859858521574e-02 -6.277244073332632901e-02 -1.903552999494984022e-02 1.025375794049160350e-02 -1.097075016073090215e-03 -5.379827426551375691e-02 -2.094588005309211409e-02 -2.364953944195369306e-02 -2.383070948888221796e-02 -1.750399960104281893e-02 1.497421083089922611e-02 2.725070332141532603e-02 7.403530041943423567e-02 3.001483011466621331e-02 4.337594882232209681e-02 6.706027060741315271e-02 7.233079294473854226e-02 1.292045961433705981e-01 1.877234340958466863e-02 6.212823063689587588e-02 8.667098195715983167e-02 7.350219246286576746e-02 3.159743487146293717e-02 5.139887107014962098e-02 1.935309979350974263e-02 -3.410445703281306251e-04 9.794976840847402499e-03 -6.959086538445014014e-03 1.201927489478310518e-02 1.439413096064678932e-02 -4.486192051086429489e-02 -1.529194554502161241e-02 -3.072446651081427171e-02 -3.430002826759373513e-02 1.718162677056368770e-02 3.225957229830100914e-03 -1.497698355531706937e-02 -1.331288468251978774e-02 1.659058944413624448e-02 2.663588063070934653e-02 -5.922524084111119302e-03 5.636060111551793872e-03 -2.049342974060008871e-02 -3.803998428758581518e-02 1.830300118925570763e-03 3.424729726582459444e-02 -2.895366428311385576e-02 -3.386403989355701860e-02 -7.079295637878763037e-02 -7.093079263306317772e-02 3.198451446435424117e-02 9.545864656146652028e-02 -7.516704766287746198e-02 -8.108517870498599400e-02 -1.177430403484454047e-01 -3.120935658466644780e-02 9.223154995107774035e-02 -1.941212424528665492e-02 3.411902669265831634e-03 -2.354139203324806529e-03 -3.071645493442498598e-02 -4.164925521383888718e-02 -3.122691837708191365e-02 2.883660684356703641e-02 -5.717969520583865428e-02 -6.697810496817224735e-03 9.441536785215753902e-03 4.728317922800373552e-03 2.049464471048090264e-03 5.739566329777823217e-02 7.567444227145320168e-02 5.682425425263715191e-02 2.127495371418597347e-02 5.243610080135335805e-02 6.029907063806672074e-02 6.969759432272237820e-02 5.641399207835956497e-02 7.288261681999158581e-02 5.756469121404828027e-02 7.178193358914231048e-02 5.381813355449260872e-02 9.644985199153865985e-02 6.435194910225061626e-02 1.117112490506719791e-01 2.439163554038270565e-02 2.557084230623229981e-03 2.469910898473459682e-02 -9.569424158990702534e-03 -5.173909847879420987e-02 -2.771943460190381958e-02 -7.918742305681764071e-03 -3.247312870800173057e-02 -3.910586948488503634e-03 -3.242901716659532529e-02 6.020118668182583566e-03 1.858335310757686099e-02 1.685456044577338108e-02 -3.478529517587825026e-02 -5.549822951020677575e-02 1.016235026400252872e-02 2.200445534907724543e-02 3.048728364537484081e-02 3.272163712735043362e-02 2.395435266492118576e-02 2.480370438536083633e-02 1.056266120762306415e-01 -1.082460774310889384e-01 -1.347452419485566932e-01 -7.714839854654403917e-02 -1.900100074423183294e-02 -2.368723808155448474e-03 0.000000000000000000e+00 -2.355757032900079873e-02 9.196526397255683216e-03 -1.249529199393473178e-03 -3.236878688899802459e-02 -3.136013706852952554e-02 -5.156107379348240372e-04 -1.377622880706341757e-01 -2.396047220463182192e-02 -9.684884856711595269e-02 -1.842852002418049473e-02 -3.176145780247169315e-02 -4.241533961730808988e-02 -2.973026167434550393e-02 -1.646074567045308079e-02 6.668870098842760719e-03 5.033457963755305631e-02 2.969935511689753005e-02 5.231368543525652393e-02 5.162632846998616021e-02 7.889039094445621236e-02 8.296260101450758651e-02 9.697524611355656798e-02 8.633834112993971077e-02 1.005506084517912013e-01 1.164298262869764011e-01 1.025027965383787376e-01 1.135352705294886966e-01 1.008843418671770964e-01 1.088638311190759378e-01 2.884552324651995514e-02 3.991830833263365630e-02 4.760570909695638342e-02 1.693027396115567851e-02 3.933182809711910366e-02 -6.408816681512249924e-02 -5.529609835923893213e-02 -2.993717135309542643e-02 -8.085331618384095087e-03 -6.185204488784304400e-02 -1.196921502674397897e-01 -4.780768033549070983e-02 -1.274389715508722487e-02 -1.280925978066266291e-02 -4.849996655662441869e-02 -3.646866106294993637e-02 -2.756873004038262742e-02 -5.356826427281805025e-02 -6.242776544651362780e-02 -6.124211990236372305e-02 -5.686055405028850318e-02 -2.817431694836830536e-02 1.500375567808898136e-02 -6.187659459197802914e-02 -5.409826477572732273e-02 2.261388915804851685e-02 6.426257712815597323e-02 1.157463639073508244e-02 5.004890564395303443e-02 -3.950616854542954304e-03 -6.239557142348028940e-02 -8.200269713949936978e-03 -1.251492744667737078e-03 -1.265801790937595150e-01 -1.768421559080157746e-02 2.027397358647520242e-02 4.478253635871065619e-03 1.878158237154076149e-02 6.594154561536602621e-02 7.452069498742991405e-02 7.496480550402284670e-02 9.538428783854202564e-02 1.038856363174851527e-01 1.424821557236105596e-01 1.308412610257474462e-01 1.168959152275381719e-01 7.850467133577615497e-02 7.777115662308897726e-02 5.981982514235850701e-02 8.319277680590930757e-02 5.805864235677821172e-02 3.503989261654183451e-02 6.941485649918266443e-02 3.136830512895127931e-02 2.623864649120127845e-02 -1.226727174267633336e-02 1.110223024625156540e-16 -7.376709615168980383e-03 -9.038478471914745960e-03 6.986774001545778545e-03 -3.856365183713572620e-03 -8.619184960484249647e-03 -3.262580246123072958e-02 -4.651261401455147881e-02 -3.236697476015598651e-02 -1.641180100241046436e-02 -6.535594391774748879e-02 -1.126080952657532719e-01 -1.189511381184812644e-01 -5.890481919610351946e-02 -5.552142369774434871e-02 -6.347500718128468167e-02 -7.750984210293726528e-02 -4.330385478438258939e-02 -7.595236886221326533e-02 -1.040841842177327170e-01 -7.866565189792984469e-02 -9.107533039278314924e-02 -9.729503258398433663e-02 -5.155961606225628602e-02 5.716840813781481900e-02 -1.467829770886464047e-02 3.556038290053020745e-03 2.142707048989228591e-02 -3.531625991868403425e-03 4.356573820064091329e-02 -5.679040673184049259e-02 -1.487776052507348845e-02 -8.124221123796410149e-02 -5.060338391158325511e-03 -8.053437474883629044e-03 -1.801016783423853296e-02 -1.279701804251587305e-02 -1.642983927022667601e-02 -1.281404297380123181e-02 -3.444779062880543030e-03 1.814529853593149777e-02 3.516420765789823877e-02 2.194975082694949897e-02 2.529998463330923597e-02 4.464264850721472166e-02 7.643078317437868030e-02 7.041322144265371730e-02 8.296155058167570262e-02 6.615983653818824362e-02 4.794770816378934875e-02 8.856734114244479983e-02 1.258800873696094280e-01 1.389593385184824115e-01 1.498281355904477197e-01 1.224574555233136630e-01 5.483186431966596830e-02 5.535402888271356847e-02 5.142137446889100127e-02 7.029411589955203432e-02 5.593633317006369010e-02 4.714150671382522084e-02 1.297478763856257933e-02 4.059793489800239685e-02 -3.198355232442939844e-03 -1.578471874227083127e-02 4.172631884570843219e-04 -5.481128123112230521e-03 3.958899824310690985e-03 4.854634907375310338e-02 4.584641828536167862e-02 1.283691456912186557e-02 2.086772456778712703e-04 -3.883286527456911164e-03 -6.978568771350529554e-03 -8.249607438330544551e-03 -1.821024504781104669e-02 -6.823049190367941330e-02 -2.846369680876015273e-02 -4.060232727333634717e-03 -9.065014927890668872e-02 -8.837841688435754683e-02 -1.078654283198097197e-01 -3.953937130379669984e-02 -2.733287728915720360e-02 -8.152640242757383526e-02 -1.308357512176841209e-01 -8.044444184031515621e-02 -6.068031562392728340e-02 1.875986720832878429e-02 -5.897929249547850805e-02 7.073991497246079341e-03 -6.090570638678616255e-02 -5.462943813919063363e-02 -3.270271938640623155e-02 -3.791898647128666422e-02 1.684196769300894125e-02 5.299040124461584789e-02 1.727334198115798580e-02 -3.262538445267304521e-02 -6.460900206302327975e-03 -4.187876007718888127e-03 2.104051828145839242e-03 -6.456440906927712886e-02 -8.241220464780019128e-02 -1.584243463877277325e-02 -4.451124106025378113e-02 6.204589027608536922e-02 -5.111202513504803369e-02 -3.414571659963860917e-02 -5.465147093469502337e-02 -4.490135130341305070e-02 3.297457022298994067e-02 1.138019688518973616e-01 4.166481086785100985e-02 2.925682593430106726e-02 8.335791832102096288e-02 1.134549440008136845e-01 5.318986808574899250e-02 6.326665121558505689e-02 2.901205218965235977e-02 2.709286653167519709e-02 6.061274790290466230e-02 1.854683369224696676e-02 2.902103450321780187e-02 -1.466493757378331542e-02 -8.450799006366985222e-03 3.238752353295620834e-02 6.883611128938593726e-03 6.304336365859447566e-03 2.662321664874278682e-02 2.746320655555406498e-02 3.603443934644601221e-02 2.116640782743439697e-02 5.846297720502810491e-03 6.489046663897499179e-02 -2.212720929445577411e-03 -2.189626238306757733e-02 1.809448480885464394e-02 -4.258279898892736171e-02 1.815539971975982381e-02 -6.637756744883388516e-02 -1.195477794535662885e-01 -7.761629593318347675e-02 -6.528221527559652237e-02 -7.510948509456635835e-02 -3.241960469112911691e-02 -5.811779465876976136e-02 -7.162919591932115360e-02 -1.017479140369489388e-01 -6.804471305478898557e-02 -3.655182112120397564e-02 -3.468655899873923643e-02 -7.787662238841774887e-02 -6.998641259933852110e-02 -4.354185850015890313e-02 -5.011636796222052048e-02 -3.801528925170127859e-02 1.260090902987887063e-02 4.423447876462893724e-02 1.283787124659774292e-02 4.949812209368315008e-02 -7.727269529949953863e-03 9.282469058985345911e-03 -1.151166856591892551e-02 -5.171058003512418733e-03 -1.198847871951366773e-02 -1.294468509956125946e-03 2.798713296447363774e-02 3.586060178983307978e-02 -7.076132206619289988e-04 -9.774184452153625302e-02 -1.060006385825577602e-01 -6.756566877045661057e-02 -1.298748714533518867e-01 -1.005912904186360146e-01 -9.437547579407315479e-02 -5.801209316061123333e-02 -4.550554546462615146e-02 -2.970686610155373608e-02 2.036190620496108883e-02 -6.334074918455723235e-03 1.300144335549104913e-01 8.996752652747164181e-02 -3.443754124748399370e-03 2.744909628221592346e-02 8.856880872205730171e-02 3.401716662605136499e-02 9.291635086396965448e-03 2.668220571054702450e-02 3.144660703649948541e-02 4.554336909825346114e-02 7.471406035640879018e-03 4.177724765576401600e-03 2.949815659979121429e-03 7.726256994904215358e-03 -1.183780950302602830e-02 -8.331527641184180433e-03 -6.449427336969112967e-03 -2.357439184548476563e-03 1.572601140811527576e-02 5.618800754135233610e-03 -4.734364951055336501e-03 -4.310085917632522357e-02 -1.000801848423465978e-02 -7.031537055423214833e-02 -9.082154353565163873e-02 -7.165060423128888356e-02 -4.435286882606784276e-02 -5.449526586614975021e-02 -5.823660056605653446e-02 -1.177647112629865989e-01 -1.460010232247108408e-01 -9.955322836098917660e-02 -1.104748314340267545e-01 -7.259346385162268600e-02 -1.106944801930266620e-02 -3.681924821616411325e-02 -9.659448510554280443e-03 -1.843394276381193908e-02 3.517119076792252219e-03 3.530318740158017166e-02 -2.448237276752554537e-02 -8.324086961505566817e-02 -5.846226565018575183e-02 -4.413306998637939182e-02 -3.028123726983295017e-02 -1.749517293355967729e-02 -4.239388057717285996e-02 -7.463936401822154898e-02 -7.610312681716457917e-02 -3.400887292327570144e-02 1.279300671485920637e-01 -8.000494443979655479e-03 6.057720685599143895e-02 2.338262587606632081e-02 3.357008922451221178e-02 4.446097061532966466e-02 4.985567466467188957e-02 -3.729651991065656425e-02 -1.123452980897715614e-02 -1.290967152574694354e-02 -1.169785420119778818e-03 4.339304671458821261e-03 7.960208457236550572e-03 1.612425145210272248e-02 -1.357566069003079967e-02 -1.897636113688777604e-02 -2.127467682317307762e-02 5.688677706903066955e-02 1.167397147122162249e-03 -5.238090444095563902e-02 -8.033229756483753481e-02 -5.638668031346266707e-02 -8.770126909852105079e-02 -1.139703122313763251e-01 -1.091441073080444135e-01 -9.308666913218882621e-02 -1.318168247245212754e-01 2.785215405331337157e-02 -1.706111939405730027e-03 -1.044319809233721918e-01 -1.517829994094719304e-01 -1.054769050331120228e-01 1.423877469064789847e-01 1.153685494681763735e-02 -8.706359502361496472e-03 1.135425261481345927e-03 1.441192789427614418e-03 -1.482166852378000166e-02 -2.741693694998395547e-02 3.842834910067111087e-02 -3.016686231083920422e-03 -6.272337600095162502e-02 -2.945125575841017751e-02 -8.265012146342437527e-02 -6.854100855556741201e-02 -5.195084362038110415e-02 -7.411749468435571697e-02 -2.486286453376224115e-02 -6.187847656496281434e-02 -2.968894745884106956e-02 1.762643206525443818e-02 1.294560182734616482e-02 4.221917108300238253e-02 9.920310650409752684e-02 8.521827899351425151e-02 9.774522370312288544e-03 7.499195679634462763e-02 2.732722326513375988e-02 6.350451310634608326e-02 6.490460864797181761e-02 5.707981988600985268e-02 1.844500040724739165e-02 1.417147248904337964e-02 7.990194193126673450e-03 1.009520255724344340e-02 3.898843403253271500e-02 -1.155609759566522676e-02 -2.519440484900131727e-03 2.253313653278327111e-03 5.827885242445790537e-03 9.190962784846823386e-03 1.160732911085857189e-03 -5.275909555766289394e-03 3.381787516318887632e-02 -2.721033970278663450e-02 -5.244285970630779836e-02 4.875759422490227868e-02 4.600835429833582957e-03 -3.087228383610574056e-02 8.917388299658379758e-03 -3.113625653331408838e-02 -1.478572370454844798e-02 4.940881828154741751e-02 -2.336867791265717642e-02 -5.379793719052139434e-02 -4.291909741123584032e-02 -7.477199403031892233e-02 -7.442517841205104068e-02 -1.248234745779867039e-01 -1.379519428221240851e-01 -1.371746383883072351e-01 -1.410640080491438464e-01 -7.153402382767853895e-02 -7.951004471596795353e-02 -1.459334568545657129e-01 -6.895284700299986191e-03 2.746149785201490445e-03 2.308385727351258687e-03 -7.994019877111374628e-02 -5.890325063153001306e-02 -8.784983164698587088e-02 -6.129444879220657949e-02 -6.467969716770757826e-02 -5.258220008153868807e-02 -3.986417666108588165e-02 -6.480401394489507250e-02 -7.151191855893396232e-02 1.055472282177393750e-01 5.440200566045894082e-02 3.656338981196360916e-02 6.555135724368527095e-02 8.778637220420631992e-02 7.209217548046492618e-02 4.669587885186798903e-02 5.361773176019690723e-02 2.100601311910893498e-02 6.322721469066044930e-02 6.324133263799930349e-02 2.644507624189262884e-02 6.493048045675509083e-02 4.137328830399938928e-02 -1.590679399124483862e-02 1.906620985511198185e-03 1.176733236402961735e-02 -2.724327187162875474e-02 -1.694316454009803241e-03 7.151084022793061101e-03 -2.518011196291669584e-02 -6.830186397384752084e-03 3.839225472878626810e-04 -6.383522099629515556e-03 3.213803800869874383e-02 6.646280411769012186e-03 3.469305590503041214e-03 3.161514171528406747e-03 3.286238069597990918e-03 1.312624149812902097e-02 1.332620754499003191e-02 2.640736755382855350e-02 3.996890614732073743e-02 -2.128863487235810315e-02 -7.933393845336322858e-02 -3.302483636109176945e-02 -1.015654416187094511e-01 -1.325651062865587093e-01 -1.160991618245051926e-01 -1.064432056694104567e-01 -1.184449020589762869e-01 -6.400724828316428638e-02 -1.016812531739407222e-01 -7.798906219928736228e-02 -8.767094074204545562e-02 -8.131929970818713160e-03 -4.266889541076873682e-03 -8.051025079016255193e-02 -8.142489159399107779e-02 -6.463343952452976771e-02 -3.477208304841689079e-02 -6.169485922106210385e-02 -7.794801571513843008e-02 -5.875547413448400924e-02 -2.948747628264225540e-02 -2.468786350077079028e-02 6.316931852297980043e-03 1.675770593459768865e-02 8.440158329731495268e-03 3.407307521354102642e-02 4.046558954161111332e-02 5.333240427857222077e-02 9.984317230508371610e-02 6.380628672903065901e-02 6.821895425172957994e-02 7.726852029029263047e-02 1.099879223841040976e-01 1.154725109215001821e-01 1.289915848947860155e-01 1.168403187068005611e-01 7.601204755920465406e-02 5.760226131262197180e-02 6.111537335727673659e-02 4.615846941988716035e-02 5.338692740816225468e-02 5.555730080338849852e-02 9.043577779408418227e-02 7.540903584304714524e-02 7.434934358590894465e-02 -4.715512399759397288e-02 7.006223732701544193e-03 3.364841554370112675e-03 1.690409671780922218e-02 1.103833164924136745e-02 1.126494343287030159e-02 4.057932819030787841e-03 1.368619273598631336e-03 4.626015404370703576e-02 2.132559203921788327e-03 -1.265471233206300061e-02 -4.516990638789936119e-03 -7.155526544551302215e-03 -1.352277613288392633e-02 2.621463144352664809e-02 1.939461416689092221e-02 6.185211299288173592e-03 8.045623312930225146e-03 4.407589536537970254e-03 1.191666034032462518e-02 6.547637500250988452e-03 6.270007122786691589e-03 2.630044414796584018e-03 5.806308029044277008e-03 8.511179399315754734e-04 -2.362464244201878394e-02 -3.380972184650721246e-03 6.357541814028117022e-03 1.537197145284752153e-02 6.342725900758727775e-02 7.259079807480606217e-02 1.157786344750846297e-01 7.184128864328309660e-02 -1.035335901320000307e-02 4.168878403254561160e-02 6.321671510862214571e-02 6.721673864842980795e-02 -8.634059593854637171e-02 -6.710734873617735241e-02 -5.401885723027677333e-02 -9.033267165973468682e-02 6.077874509055947172e-03 -3.288646725657162762e-02 -6.980608224949735874e-02 -9.304199209365759948e-02 4.102947654724820037e-02 1.304906824207752170e-02 3.284161330384344213e-02 -1.083123574638507891e-01 -3.474140936233205412e-02 -3.115680830226313924e-02 -8.954540738243413345e-02 -4.195714073667794475e-02 -8.509552666629494055e-02 -9.544602778678318300e-02 -7.612007930937042532e-02 -5.777839588658773007e-02 -5.979117785777282590e-02 -9.303876566862379072e-04 -1.835442822550326092e-03 5.093692506767105721e-02 7.321897028698953758e-03 2.843994192835286317e-02 3.652328472779242663e-02 5.976919248128853557e-02 5.578086382840818924e-02 -4.312149138461496278e-02 7.607358466719998935e-02 5.186506528253109760e-02 1.066872150488835103e-01 2.317293301517714399e-02 8.358124769813657373e-02 1.212137536909758118e-01 1.088231327200454568e-01 2.702684551830986104e-02 2.980740712067009301e-02 7.117852449560413408e-02 5.029681501193783433e-02 6.926432731488418870e-02 3.138751560408248320e-02 5.240655701285723556e-02 5.934528699975138988e-02 7.562571076104612766e-02 5.959577823875922276e-02 4.831664684117192854e-03 1.507431192400966735e-02 1.757792668096593014e-03 -5.219913345067189736e-03 -7.026869437085692116e-03 -4.846569770470751659e-03 -5.317193298629660503e-03 -6.900490373682011125e-03 -4.672818975354944837e-03 -5.622143765235121382e-04 1.316040200243101532e-02 -4.197649878046133542e-03 2.545967639584312270e-03 3.191690482571410414e-03 1.116690262505298792e-03 7.411148270822009998e-03 9.477059769268714184e-03 7.852044959877985120e-03 -1.756565812885621525e-03 -4.869098454477943649e-03 -2.685139186935664446e-03 -1.085590845068482024e-02 1.059285359914305391e-02 1.849516730946226817e-02 4.222865377134421561e-02 -8.785324111355796717e-03 1.874835920114170662e-03 9.396433027552286710e-02 5.248701611436867864e-02 6.487698256645951789e-02 9.643773387012782861e-02 7.471527239577763213e-02 9.961300302901632264e-02 8.589476044726551685e-02 3.321503310077345006e-02 -1.211545818919109729e-01 5.532271038215685888e-02 -1.409394383388486438e-01 -8.514245610785636798e-02 -4.886889620580692206e-02 -4.712974967948441174e-02 -2.021370739854932985e-02 -2.971153093296480252e-02 -1.479922118615240034e-02 -1.271505988488993433e-01 1.317582259028932667e-01 4.529932159377814127e-02 1.231348201919263419e-02 -9.872668484965235747e-03 -7.924516778866730338e-02 -5.253905352146087671e-02 -4.088819168557034089e-02 -7.392603214977239157e-02 1.711047770440399240e-03 -3.491752950501547659e-02 -1.346242779247391885e-02 -2.440079125723870757e-02 -1.020757962795454388e-02 3.651582367707101318e-02 5.252042094050879406e-02 4.758564985168128869e-02 2.220446049250313081e-16 8.860686880938839494e-02 8.850994833649650229e-02 6.930848923131482930e-02 1.034439095036600031e-01 7.877308384639736261e-02 1.313369785954572877e-01 1.271483104168850686e-01 6.367449317819257049e-02 3.854436006555339578e-02 4.785932231168799067e-02 6.582239699615949347e-02 -2.446832169975494964e-03 1.222332317369036192e-02 1.034711285034142780e-02 -2.295209704164843934e-03 -1.353755519017434128e-02 -1.346053714582767791e-03 4.093075312305502478e-03 1.933078846524105554e-04 -1.002784315773430635e-02 -1.087087238633070718e-02 -1.189732614960203883e-02 -8.124852809278201859e-03 -4.803677212548401743e-03 -7.919173430258996671e-03 -5.867875309395961803e-03 -9.175338677694863665e-03 9.765872837728312161e-03 1.361864184454894544e-02 9.301200706621270964e-03 -2.026660805014443567e-03 5.906830317137512498e-04 7.382336514353160517e-03 8.410538789687949102e-03 1.535361143379543325e-02 9.231776277094427829e-03 3.122655500871762690e-03 -3.942937463410095544e-03 7.929557208005727498e-03 3.413561032196532619e-03 enter image description herejust got wrong figure[enter image description here][2], using python 3.7. import matplotlib.pyplot as plt import pandas as pd data = pd.read_csv('data.txt', header=-1) data.columns =['A'] data.hist('A', bins=20, density=True) plt.show()
A Question with using scapy.sniff for get the 'Ethernet Frame' in pcap files
Aim: Get the arrival time from the pcap files Language: python3.7 Tools: Scapy.sniff Above all ,i want get the arrival time data,in the .pcap ,when i use wireshark ,i saw the data in the Ethernet Frame,but when i use #Scapy.sniff(offline='.pcap') ,i just get the Ether,TCP,IP and others ,so how can i get that data? Thanx alot! >>from scapy.all import * >>a = sniff(offline = '***.pcap') >>a[0] [out]: <Ether dst=*:*:*:*:*:* src=*:*:*:*:*:* type=** |<IP version=4 ihl=5 tos=0x20 len=52 id=14144 flags=DF frag=0 ttl=109 proto=tcp chksum=0x5e3b src=*.*.*.* dst=*.*.*.* |<TCP sport=gcsp dport=http seq=1619409885 ack=1905830025 dataofs=8 reserved=0 flags=A window=65535 chksum=0xfdb5 urgptr=0 options=[('NOP', None), ('NOP', None), ('SAck', (1905831477, 1905831485))] |>>> [ ]:
The packet time from the pcap is available in the time member: print(a[0].time) It's kept as a floating point value (the standard python "timestamp" format). To get it in a form more easily understandable, you may want to use the datetime module: >>> from datetime import datetime >>> dt = datetime.fromtimestamp(a[0].time) >>> print(dt) 2018-11-12 03:03:00.259780 The scapy documentation isn't great. It can be very instructive to use the interactive help facility. For example, in the interpreter: $ python >>> from scapy.all import * >>> a = sniff(offline='mypcap.pcap') >>> help(a[0]) This will show you all the methods and attributes of the object represented by a[0]. In your case, that is an instance of class Ether(scapy.packet.Packet).
how to perform calculation for all elements of list parellely or simultaneously to reduce the run time?
I am extracting a dataframe from yahoo API for a list of companies but I want to do it paralelly(i.e, the dataframes for all the companies should be extracted simultaneously).So, it reduces my run time.... My code: import pandas_datareader.data as web import pandas as pd import datetime end_date = datetime.datetime.now().strftime('%d/%m/%Y') temp = datetime.datetime.now() - datetime.timedelta(6*365/12) start_date = temp.strftime('%d/%m/%Y') f = web.DataReader('ACC.NS', 'yahoo', start_date, end_date) print(f) The output of this code is a dataframe shown below: This i have done for single company.... I want to do it for a list of companies which is: Company_Names = ['ACC', 'ADANIENT', 'ADANIPORTS', 'ADANIPOWER', 'AJANTPHARM', 'ALBK', 'AMARAJABAT', 'AMBUJACEM', 'APOLLOHOSP', 'APOLLOTYRE', 'ARVIND', 'ASHOKLEY', 'ASIANPAINT', 'AUROPHARMA', 'AXISBANK', 'BAJAJ-AUTO', 'BAJFINANCE', 'BAJAJFINSV', 'BALKRISIND', 'BANKBARODA', 'BANKINDIA', 'BATAINDIA', 'BEML', 'BERGEPAINT', 'BEL', 'BHARATFIN', 'BHARATFORG', 'BPCL', 'BHARTIARTL', 'INFRATEL', 'BHEL', 'BIOCON', 'BOSCHLTD', 'BRITANNIA', 'CADILAHC', 'CANFINHOME', 'CANBK', 'CAPF', 'CASTROLIND', 'CEATLTD', 'CENTURYTEX', 'CESC', 'CGPOWER', 'CHENNPETRO', 'CHOLAFIN', 'CIPLA', 'COALINDIA', 'COLPAL', 'CONCOR', 'CUMMINSIND', 'DABUR', 'DCBBANK', 'DHFL', 'DISHTV', 'DIVISLAB', 'DLF', 'DRREDDY', 'EICHERMOT', 'ENGINERSIN', 'EQUITAS', 'ESCORTS', 'EXIDEIND', 'FEDERALBNK', 'GAIL', 'GLENMARK', 'GMRINFRA', 'GODFRYPHLP', 'GODREJCP', 'GODREJIND', 'GRANULES', 'GRASIM', 'GSFC', 'HAVELLS', 'HCLTECH', 'HDFCBANK', 'HDFC', 'HEROMOTOCO', 'HEXAWARE', 'HINDALCO', 'HCC', 'HINDPETRO', 'HINDUNILVR', 'HINDZINC', 'ICICIBANK', 'ICICIPRULI', 'IDBI', 'IDEA', 'IDFCBANK', 'IDFC', 'IFCI', 'IBULHSGFIN', 'INDIANB', 'IOC', 'IGL', 'INDUSINDBK', 'INFIBEAM', 'INFY', 'INDIGO', 'IRB', 'ITC', 'JISLJALEQS', 'JPASSOCIAT', 'JETAIRWAYS', 'JINDALSTEL', 'JSWSTEEL', 'JUBLFOOD', 'JUSTDIAL', 'KAJARIACER', 'KTKBANK', 'KSCL', 'KOTAKBANK', 'KPIT', 'L&TFH', 'LT', 'LICHSGFIN', 'LUPIN', 'M&MFIN', 'MGL', 'M&M', 'MANAPPURAM', 'MRPL', 'MARICO', 'MARUTI', 'MFSL', 'MINDTREE', 'MOTHERSUMI', 'MRF', 'MCX', 'MUTHOOTFIN', 'NATIONALUM', 'NBCC', 'NCC', 'NESTLEIND', 'NHPC', 'NIITTECH', 'NMDC', 'NTPC', 'ONGC', 'OIL', 'OFSS', 'ORIENTBANK', 'PAGEIND', 'PCJEWELLER', 'PETRONET', 'PIDILITIND', 'PEL', 'PFC', 'POWERGRID', 'PTC', 'PNB', 'PVR', 'RAYMOND', 'RBLBANK', 'RELCAPITAL', 'RCOM', 'RELIANCE', 'RELINFRA', 'RPOWER', 'REPCOHOME', 'RECLTD', 'SHREECEM', 'SRTRANSFIN', 'SIEMENS', 'SREINFRA', 'SRF', 'SBIN', 'SAIL', 'STAR', 'SUNPHARMA', 'SUNTV', 'SUZLON', 'SYNDIBANK', 'TATACHEM', 'TATACOMM', 'TCS', 'TATAELXSI', 'TATAGLOBAL', 'TATAMTRDVR', 'TATAMOTORS', 'TATAPOWER', 'TATASTEEL', 'TECHM', 'INDIACEM', 'RAMCOCEM', 'SOUTHBANK', 'TITAN', 'TORNTPHARM', 'TORNTPOWER', 'TV18BRDCST', 'TVSMOTOR', 'UJJIVAN', 'ULTRACEMCO', 'UNIONBANK', 'UBL', 'UPL', 'VEDL', 'VGUARD', 'VOLTAS', 'WIPRO', 'WOCKPHARMA', 'YESBANK', 'ZEEL'] For all this companies the dataframe 'f' should be extracted parallely in order to save run time. Can anyone help me to solve this?