Numpy Pandas Matplotlib Tutorial - Jupyter Notebook
Numpy Pandas Matplotlib Tutorial - Jupyter Notebook
[Link]
([Link]
In [2]: 1 a=[Link]([1,2,3,4,5])
2 b=[Link]([1,2,3,4,5])
3 print(a)
4 print(b)
[1 2 3 4 5]
[1 2 3 4 5]
Out[3]: [Link]
In [4]: 1 type(b)
Out[4]: [Link]
if you want to define a data type of an array then We use [Link](arr,dtype= " define variable
type")
In [5]: 1 a=[Link]([1,2,3,4,5])
2 [Link]# tells a data type of an elements stored in an array
Out[5]: dtype('int32')
In [6]: 1 a=[Link]([1,2,3,4,5],dtype="float")
2 print(a)
3 [Link]
[1. 2. 3. 4. 5.]
Out[6]: dtype('float64')
syntax:
copy :f true (default), then the object is copied. Otherwise, a copy will only be made if array
returns a copy, if obj is a nested sequence, or if a copy is needed to satisfy any of the other
requirements (dtype, order, etc.).
subok:bool, optional: If True, then sub-classes will be passed-through, otherwise the returned
array will be forced to be a base-class array (default).
ndmin (int, optional): Specifies the minimum number of dimensions that the resulting array
should have. Ones will be prepended to the shape as needed to meet this requirement.
Out[9]: 2
In [15]: 1 b=[Link]([[[1,2,3,4],[1,23,45,7]],[[1,2,3,45],[25,67,89,46]]])
2 [Link]
Out[15]: 3
In [16]: 1 print([Link][0],[Link][1],[Link][2])
2 2 4
In [17]: 1 c=[Link]([[[1,2,3],[12,23,34],[2,3,4,]],[[1,2,3],[2,3,5],[23,34,45]]])
In [18]: 1 [Link]
Out[18]: (2, 3, 3)
In [19]: 1 [Link][0]
Out[19]: 2
In [20]: 1 [Link]
Out[20]: 3
Out[21]: 3
In [22]: 1 A=[Link]([2])
2 [Link]
Out[22]: 2
Out[23]: 0
In [24]: 1 [Link]
2 # size of an array means total no of elements in an array
Out[24]: 18
In [25]: 1 [Link]
2 # total no of bytes ARE taking inside
Out[25]: 72
Numpy([Link],reshape,random)
start:(integer or real, optional) Start of interval. The interval includes this value. The default start
value is 0
stop:(integer or real)
End of interval. The interval does not include this value, except in some cases where step is
not an integer and floating point round-off affects the length of out.
In [27]: 1 [Link](3,7,2)
In [28]: 1 A=[Link](100)
2 A
Out[29]: array([20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59, 62, 65, 68,
71, 74, 77, 80, 83, 86, 89, 92, 95, 98])
In [30]: 1 print(list(range(1,10)))
[1, 2, 3, 4, 5, 6, 7, 8, 9]
[Link](x)
x=int or array
In [31]: 1 [Link]([Link](10))
[Link]
Return random integers from the “discrete uniform” distribution of the specified dtype in the
“half-open” interval [low, high). If high is None (the default), then results are from [0, low).
low:
Lowest (signed) integers to be drawn from the distribution (unless high=None, in which case
this parameter is one above the highest such integer).
If provided, one above the largest (signed) integer to be drawn from the distribution (see above
for behavior if high=None). If array-like, must contain integer values
Output shape. If the given shape is, e.g., (m, n, k), then m * n * k samples are drawn. Default is
None, in which case a single value is returned.
In [32]: 1 a=[Link](20,30)
2 a
Out[32]: 25
In [33]: 1 type(a)
Out[33]: int
In [39]: 1 [Link]
Out[39]: dtype('uint8')
[Link]
In [42]: 1 b=[Link](100000)
In [43]: 1 [Link](b,bins=200)
, , , , ,
3.85247153, 3.89550465, 3.93853777, 3.98157088, 4.024604 ,
4.06763712, 4.11067024, 4.15370336, 4.19673648, 4.23976959,
4.28280271]),
<BarContainer object of 200 artists>)
In [44]: 1 c=[Link](2,3)
2 c
In [45]: 1 [Link]
Out[45]: 2
In [46]: 1 f=[Link](2,3,4,2)
In [47]: 1 f
[[0.9918514 , 0.59811509],
[0.18041814, 0.16472693],
[0.61518047, 0.07070645],
[0.37736273, 0.80914649]],
[[0.6840498 , 0.08701545],
[0.97204267, 0.61803372],
[0.83348168, 0.03573135],
[0.72095525, 0.87603509]]],
[[[0.16955355, 0.30847154],
[0.80869495, 0.99278668],
[0.39943373, 0.44563388],
[0.01930691, 0.25126703]],
[[0.93256054, 0.57091998],
[0.64571133, 0.42720771],
[0.24318278, 0.36551387],
[0.56897703, 0.33657849]],
[[0.10234947, 0.1445751 ],
[0.03456438, 0.22017005],
[0.67139146, 0.27889377],
[0.49990398, 0.87893307]]]])
In [48]: 1 [Link]
Out[48]: 4
For any output out, this is the distance between two adjacent values, out[i+1] - out[i].
In [50]: 1 c
In [51]: 1 [Link]
In [52]: 1 c=[Link](100).reshape(4,5,5)
2 c
In [53]: 1 [Link]
Out[53]: (4, 5, 5)
Original array :
[0 1 2 3 4 5 6 7]
[[4 5]
[6 7]]]
[Link](shape, dtype = None, order = 'C')
function returns a new array of given shape and type, with zeros.
Matrix b :
[0 0]
Matrix a :
[[0 0]
[0 0]]
Matrix c :
[[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]]
function returns a new array of given shape and type, with ones.
Matrix b :
[1 1]
Matrix a :
[[1 1]
[1 1]]
Matrix c :
[[1. 1. 1.]
[1. 1. 1.]
[1. 1. 1.]]
Silcing
A[Start:end:step]
In [57]: 1 A=[Link](100)
2 A
In [58]: 1 b=A[3:10]
In [59]: 1 b
In [60]: 1 b[0]=-1200
In [61]: 1 b
In [62]: 1 A
In [63]: 1 b=A[3:10].copy()
In [64]: 1 b
In [65]: 1 A[::5]
Out[65]: array([ 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80,
85, 90, 95])
In [66]: 1 A[::-5]
Out[66]: array([99, 94, 89, 84, 79, 74, 69, 64, 59, 54, 49, 44, 39, 34, 29, 24, 19,
14, 9, 4])
In [67]: 1 A[::-1]
Out[67]: array([ 99, 98, 97, 96, 95, 94, 93, 92, 91,
90, 89, 88, 87, 86, 85, 84, 83, 82,
81, 80, 79, 78, 77, 76, 75, 74, 73,
72, 71, 70, 69, 68, 67, 66, 65, 64,
63, 62, 61, 60, 59, 58, 57, 56, 55,
54, 53, 52, 51, 50, 49, 48, 47, 46,
45, 44, 43, 42, 41, 40, 39, 38, 37,
36, 35, 34, 33, 32, 31, 30, 29, 28,
27, 26, 25, 24, 23, 22, 21, 20, 19,
18, 17, 16, 15, 14, 13, 12, 11, 10,
9, 8, 7, 6, 5, 4, -1200, 2, 1,
0])
In [68]: 1 [Link]?
In [70]: 1 idx
Out[70]: 3
[Link](arr)
function is used to find the indices of array elements that are non-zero, grouped by element
In [71]: 1 A[idx]=3
In [72]: 1 A
In [74]: 1 A
In [75]: 1 A[1,2]
Out[75]: 5.0
In [76]: 1 A[1,:]
In [77]: 1 A[:,1]
In [78]: 1 A[::2,:]
In [79]: 1 A[1:3,2:4]
In [83]: 1 A
In [85]: 1 A
A[index_array]
In [86]: 1 A=[Link](100)
2 B=A[[3,5,6]]
In [87]: 1 B
In [88]: 1 B[0]=-4
2 B
In [90]: 1 B
In [92]: 1 B
Out[92]: array([31, 32, 33, 34, 35, 36, 37, 38, 39])
&-array,and-object
/-array, or-object
~ array,not -object
[Link](tup)
[Link]() function is used to stack the sequence of input arrays horizontally (i.e. column
wise) to make a single array.
Syntax : [Link](tup)
Parameters : tup : [sequence of ndarrays] Tuple containing arrays to be stacked. The arrays
must have the same shape along all but the second axis.
[Link](tup)
[Link]() function is used to stack the sequence of input arrays vertically to make a
single array.
Syntax : [Link](tup)
Parameters : tup : [sequence of ndarrays] Tuple containing arrays to be stacked. The arrays
must have the same shape along all but the first axis.
[Link]()
arr : Array to be sorted.
axis : Axis along which we need array to be started.
Pandas
In [98]: 1 import pandas as pd
Parameters:
data-array-like, Iterable, dict, or scalar value Contains data stored in Series. If data is a dict,
argument order is maintained.
index-array-like or Index (1d) Values must be hashable and have the same length as data.
Non-unique index values are allowed. Will default to RangeIndex (0, 1, 2, …, n) if not provided.
If data is dict-like and index is None, then the keys in the data are used as the index. If the
index is not None, the resulting Series is reindexed with the index values.
dtype-str, [Link], or ExtensionDtype, optional Data type for the output Series. If not
specified, this will be inferred from data. See the user guide for more usages.
copy-bool default False Copy input data Only affects Series or 1d ndarray input See
Out[99]: a 1
b 2
c 3
dtype: int64
The keys of the dictionary match with the Index values, hence the Index values have no effect
Out[100]: x NaN
y NaN
z NaN
dtype: float64
Note that the Index is first build with the keys from the dictionary. After this the Series is
reindexed with the given Index values, hence we get all NaN as a result.
Out[101]: [1, 2]
In [102]: 1 print(ser)
0 999
1 2
dtype: int64
Due to input data type the Series has a copy of the original data even though copy=False, so
the data is unchanged.
In [103]: 1 data=[Link]([0.25,0.3,5,7],index=["1","2","3","5"])
2 data
Out[103]: 1 0.25
2 0.30
3 5.00
5 7.00
dtype: float64
Out[106]: '1.3.4'
In [107]: 1 type([Link])
Out[107]: [Link]
In [108]: 1 type([Link])
Out[108]: [Link]
In [109]: 1 data["2":"5"]
Out[109]: 2 0.3
3 5.0
5 7.0
dtype: float64
In [110]: 1 grades_dict={"A":2,"B":2.5,"C":3,"D":3.5}
2 grads=[Link](grades_dict)
3 grads
Out[110]: A 2.0
B 2.5
C 3.0
D 3.5
dtype: float64
In [111]: 1 marks_dict={"A":85,"B":75,"C":70,"D":65}
2 marks=[Link](marks_dict)
In [112]: 1 marks
Out[112]: A 85
B 75
C 70
D 65
dtype: int64
[Link](data=None, index=None,
columns=None, dtype=None, copy=None)
[source]
Two-dimensional, size-mutable, potentially heterogeneous tabular data.
Data structure also contains labeled axes (rows and columns). Arithmetic operations align on
both row and column labels. Can be thought of as a dict-like container for Series objects. The
primary pandas data structure.
Parameters:
index:Index or array-like Index to use for resulting frame. Will default to RangeIndex if no
indexing information part of input data and no index provided.
columns:Index or array-like Column labels to use for resulting frame when data does not have
them, defaulting to RangeIndex(0, 1, 2, …, n). If data contains column labels, will perform
column selection instead.
dtype:dtype, default None Data type to force. Only a single dtype is allowed. If None, infer.
copy:bool or None, default None Copy data from inputs. For dict data, the default of None
behaves like copy=True. For DataFrame or 2d ndarray input, the default of None behaves like
copy=False. If data is a dict containing one or more Series (possibly of different dtypes),
copy=False will ensure that these inputs are not copied.
In [113]: 1 d = {'col1': [1, 2], 'col2': [3, 4]}
2 df = [Link](data=d)
3 df
Out[113]:
col1 col2
0 1 3
1 2 4
In [114]: 1 [Link]
Out[116]:
col1 col2
0 0 NaN
1 1 NaN
2 2 2.0
3 3 3.0
In [117]: 1 rs=[Link]({"grades":grads,"marks":marks})
2 rs
Out[117]:
grades marks
A 2.0 85
B 2.5 75
C 3.0 70
D 3.5 65
In [118]: 1 rs.T #transpose
Out[118]:
A B C D
In [119]: 1 [Link]
Out[120]: 3.0
In [123]: 1 rs
Out[123]:
grades marks Scale_marks
A 2.0 85 94.444444
B 2.5 75 83.333333
C 3.0 70 77.777778
D 3.5 65 72.222222
In [125]: 1 rs
Out[125]:
grades marks
A 2.0 85
B 2.5 75
C 3.0 70
D 3.5 65
In [126]: 1 rs[rs["marks"]>75]
Out[126]:
grades marks
A 2.0 85
In [127]: 1 A=[Link]([{'a':1,"b":2},{"b":7,"c":2}])
In [128]: 1 A
Out[128]:
a b c
0 1.0 2 NaN
1 NaN 7 2.0
Out[129]: a 1
b 0
c 1
dtype: int64
In [130]: 1 [Link]()
Out[130]:
a b c
In [131]: 1 A=[Link](0)
In [132]: 1 A
Out[132]:
a b c
0 1.0 2 0.0
1 0.0 7 2.0
In [133]: 1 [Link]?
In [134]: 1 A=[Link](["a","b","c"],index=[1,3,4])
2 A
Out[134]: 1 a
3 b
4 c
dtype: object
In [135]: 1 A[1]
Out[135]: 'a'
In [136]: 1 A[1:3]
Out[136]: 3 b
4 c
dtype: object
In [137]: 1 [Link][1:3]
Out[137]: 1 a
3 b
dtype: object
In [138]: 1 [Link][1:3]
Out[138]: 3 b
4 c
dtype: object
In [139]: 1 [Link][:,0:]
Out[139]:
grades marks
A 2.0 85
B 2.5 75
C 3.0 70
D 3.5 65
Covid-19 dataset
In [140]: 1 import pandas as pd
2 import numpy as np
3 from [Link] import SimpleImputer
In [141]: 1 df=pd.read_csv(r"C:\Users\VAISHNAVI\Downloads\[Link]")
In [142]: 1 df
Out[142]:
Deaths
New New New
Country/Region Confirmed Deaths Recovered Active / 100
cases deaths recovered
Cases
... ... ... ... ... ... ... ... ... ...
In [143]: 1 [Link]
<class '[Link]'>
RangeIndex: 187 entries, 0 to 186
Data columns (total 15 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 Country/Region 187 non-null object
1 Confirmed 187 non-null int64
2 Deaths 187 non-null int64
3 Recovered 187 non-null int64
4 Active 187 non-null int64
5 New cases 187 non-null int64
6 New deaths 187 non-null int64
7 New recovered 187 non-null int64
8 Deaths / 100 Cases 187 non-null float64
9 Recovered / 100 Cases 187 non-null float64
10 Deaths / 100 Recovered 187 non-null float64
11 Confirmed last week 187 non-null int64
12 1 week change 187 non-null int64
13 1 week % increase 187 non-null float64
14 WHO Region 187 non-null object
dtypes: float64(4), int64(9), object(2)
memory usage: 22.0+ KB
In [145]: 1 [Link]
Out[146]: Country/Region 0
Confirmed 0
Deaths 0
Recovered 0
Active 0
New cases 0
New deaths 0
New recovered 0
Deaths / 100 Cases 0
Recovered / 100 Cases 0
Deaths / 100 Recovered 0
Confirmed last week 0
1 week change 0
1 week % increase 0
WHO Region 0
dtype: int64
In [147]: 1 [Link]()
Out[147]:
Deaths R
New New New
Country/Region Confirmed Deaths Recovered Active / 100
cases deaths recovered
Cases
Out[148]:
Deaths R
New New New
Country/Region Confirmed Deaths Recovered Active / 100
cases deaths recovered
Cases
Antigua and
5 86 3 65 18 4 0 5 3.49
Barbuda
In [149]: 1 [Link]()
Out[149]:
Deaths
New New New
Country/Region Confirmed Deaths Recovered Active / 100
cases deaths recovered
Cases
Out[150]:
Deaths
New New New
Country/Region Confirmed Deaths Recovered Active / 100
cases deaths recovered
Cases
In [151]: 1 [Link]
Out[153]:
New New New
Country/Region WHO Region Deaths Recovered Active
cases deaths recovered
Eastern
0 Afghanistan 1269 25198 9796 106 10 18
Mediterranean
Eastern
184 Yemen 483 833 375 10 4 36
Mediterranean
A groupby operation involves some combination of splitting the object, applying a function, and
combining the results. This can be used to group large amounts of data and compute
operations on these groups.
Parameters:
by:mapping, function, label, [Link] or list of such Used to determine the groups for the
groupby. If by is a function, it’s called on each value of the object’s index. If a dict or Series is
passed, the Series or dict VALUES will be used to determine the groups (the Series’ values are
first aligned; see .align() method). If a list or ndarray of length equal to the selected axis is
passed (see the groupby user guide), the values are used as-is to determine the groups. A
label or list of labels may be passed to group by the columns in self. Notice that a tuple is
interpreted as a (single) key.
axis:{0 or ‘index’, 1 or ‘columns’}, default 0 Split along rows (0) or columns (1). For Series this
parameter is unused and defaults to 0.
level:int, level name, or sequence of such, default None If the axis is a MultiIndex
(hierarchical), group by a particular level or levels. Do not specify both by and level.
as_index:bool, default True For aggregated output, return object with group labels as the index.
Only relevant for DataFrame input. as_index=False is effectively “SQL-style” grouped output.
sort:bool, default True Sort group keys. Get better performance by turning this off. Note this
does not influence the order of observations within each group. Groupby preserves the order of
rows within each group.
Changed in version 2.0.0: Specifying sort=False with an ordered categorical grouper will no
longer sort the values.
group_keys:bool, default True When calling apply and the by argument produces a like-
indexed (i.e. a transform) result, add group keys to index to identify pieces. By default group
keys are not included when the result’s index (and column) labels match the inputs, and are
included otherwise.
Changed in version 1.5.0: Warns that group_keys will no longer be ignored when the result
from apply is a like-indexed Series or DataFrame. Specify group_keys explicitly to include the
group keys or not.
observed:bool, default False This only applies if any of the groupers are Categoricals. If True:
only show observed values for categorical groupers. If False: show all values for categorical
groupers.
dropna:bool, default True If True, and if group keys contain NA values, NA values together with
row/column will be dropped. If False, NA values will also be treated as the key in groups.
Out[155]:
Deaths Rec
New New New
Country Confirmed Deaths Recovered Active / 100
cases deaths recovered
Cases
... ... ... ... ... ... ... ... ... ...
West Bank
182 10621 78 3752 6791 152 2 0 0.73
and Gaza
Western
183 10 1 8 1 0 0 0 10.00
Sahara
Descriptive statistics include those that summarize the central tendency, dispersion and shape
of a dataset’s distribution, excluding NaN values.
Analyzes both numeric and object series, as well as DataFrame column sets of mixed data
types. The output will vary depending on what is provided. Refer to the notes below for more
detail.
percentile:slist-like of numbers, optional The percentiles to include in the output. All should fall
between 0 and 1. The default is [.25, .5, .75], which returns the 25th, 50th, and 75th
percentiles.
include:‘all’, list-like of dtypes or None (default), optional A white list of data types to include in
the result. Ignored for Series. Here are the options:
exclude:list-like of dtypes or None (default), optional, A black list of data types to omit from the
result. Ignored for Series. Here are the options:
In [156]: 1 [Link]()
Out[156]:
In [157]: 1 df1=[Link](df["Country"])[["Confirmed","Deaths"]].sum()
In [158]: 1 df1
Out[158]:
Confirmed Deaths
Country
Andorra 907 52
Angola 950 41
Western Sahara 10 1
Zimbabwe 2704 36
In [159]: 1 df3=df1[df1["Confirmed"]>1000]
2 df3
Out[159]:
Confirmed Deaths
Country
Zimbabwe 2704 36
In [161]: 1 x=[Link](0,10,1000)
2 [Link](x,[Link](x))
[Link](start, stop, num = 50, endpoint = True, retstep = False, dtype = None)
B
(array([2. , 2.25, 2.5 , 2.75, 3. ]), 0.25)
A
[0. 0.22039774 0.42995636 0.6183698 0.77637192 0.8961922
0.9719379 0.99988386 0.9786557 0.90929743]
plot() function in pyplot module of matplotlib library is used to make a 2D hexagonal binning
plot of points x, y.
x, y: These parameter are the horizontal and vertical coordinates of the data points. x values
are optional.
fmt: This parameter is an optional parameter and it contains the string value.
data: This parameter is an optional parameter and it is an object with labelled data.
[Link]()
Scatter plots are used to observe relationship between variables and uses dots to represent
the relationship between them. The scatter() method in the matplotlib library is used to draw a
scatter plot. Scatter plots are widely used to represent relation among variables and how
change in one affects the other.
In [196]: 1 [Link]()
2 x=[Link](50*[Link](50000))
3 y=[Link](200*[Link](60000))
4 z=[Link](100*[Link](50000)+1000)
5 data=[Link]({"X":x,"Y":y,"Z":z})
6 [Link]()
Out[196]:
X Y Z
[Link]() Function
bins : This parameter is an optional parameter and it contains the integer or sequence or string.
range : This parameter is an optional parameter and it the lower and upper range of the bins.
density : This parameter is an optional parameter and it contains the boolean values.
weights : This parameter is an optional parameter and it is an array of weights, of the same
shape as x.
bottom : This parameter is the location of the bottom baseline of each bin.
histtype : This parameter is an optional parameter and it is used to draw type of histogram.
{‘bar’, ‘barstacked’, ‘step’, ‘stepfilled’}
align : This parameter is an optional parameter and it controls how the histogram is plotted.
{‘left’, ‘mid’, ‘right’}
rwidth : This parameter is an optional parameter and it is a relative width of the bars as a
fraction of the bin width
log : This parameter is an optional parameter and it is used to set histogram axis to a log scale
color : This parameter is an optional parameter and it is a color spec or sequence of color
specs, one per dataset.
normed : This parameter is an optional parameter and it contains the boolean [Link] uses
the density keyword argument instead.
In [198]: 1 import matplotlib
2 import numpy as np
3 import [Link] as plt
4
5 [Link](10**7)
6 mu = 121
7 sigma = 21
8 x = mu + sigma * [Link](1000)
9
10 num_bins = 100
11
12 n, bins, patches = [Link](x, num_bins,
13 density = 1,
14 color ='green',
15 alpha = 0.7)
16
17 y = ((1 / ([Link](2 * [Link]) * sigma)) *
18 [Link](-0.5 * (1 / sigma * (bins - mu))**2))
19
20 [Link](bins, y, '--', color ='black')
21
22 [Link]('X-Axis')
23 [Link]('Y-Axis')
24
25 [Link]('[Link]() function Example\n\n',
26 fontweight ="bold")
27
28 [Link]()
n :This returns the values of the histogram bins.
patches :This returns the list of individual patches used to create the histogram.
In [199]: 1 import matplotlib
2 import numpy as np
3 import [Link] as plt
4
5 [Link](10**7)
6 n_bins = 20
7 x = [Link](10000, 3)
8
9 colors = ['green', 'blue', 'lime']
10
11 [Link](x, n_bins, density = True,
12 histtype ='bar',
13 color = colors,
14 label = colors)
15
16 [Link](prop ={'size': 10})
17
18 [Link]('[Link]() function Example\n\n',
19 fontweight ="bold")
20
21 [Link]()
In [200]: 1 x=[Link](50*[Link](50000))
2 y=[Link](200*[Link](60000))
3 z=[Link](100*[Link](50000)+1000)
In [201]: 1 [Link](x,density=True,alpha=0.5)
2 [Link](y,density=True,alpha=0.5)
3 [Link](z,density=True,alpha=0.5)
A Distplot or distribution plot, depicts the variation in the data distribution. Seaborn Distplot
represents the overall distribution of continuous data variables.
The Seaborn module along with the Matplotlib module is used to depict the distplot with
different variations in it. The Distplot depicts the data by a histogram and a line in combination
to it.
The distplot represents the univariate distribution of data i.e. data distribution of a variable
against the density distribution.
In [203]: 1 data = [Link](200)
2 res = [Link](data)
3 [Link]()
C:\Users\VAISHNAVI\anaconda3\lib\site-packages\seaborn\[Link]
9: FutureWarning: `distplot` is a deprecated function and will be removed in
a future version. Please adapt your code to use either `displot` (a figure-l
evel function with similar flexibility) or `histplot` (an axes-level functio
n for histograms).
[Link](msg, FutureWarning)
We have used the [Link]() function to generate random data values. Further,
the [Link]() function is used show the plot.
In [205]: 1 data=[Link](data)
In [207]: 1 [Link](df)
Out[208]:
X Y Z
[Link]() :
To plot multiple pairwise bivariate distributions in a dataset, you can use the .pairplot() function.
The diagonal plots are the univariate plots, and this displays the relationship for the (n, 2)
combination of variables in a DataFrame as a matrix of plots.
EXAMPLE
In [253]: 1 from sklearn import datasets
2 import pandas as pd
3
4 # load_boston() returns [Link]
5 iris= datasets.load_iris()
6 # boston_data.data is a 2D array
7 # boston_data.feature_names is an array of columns labels
8 df = [Link]([Link])
9 df['target'] = [Link]([Link])
10 [Link]()
Out[253]:
0 1 2 3 target
In [262]: 1 output_file("[Link]")
2 p=figure(plot_width=400,plot_height=400,title="line")
3 [Link]([1,2,3,4],[6,7,8,9],line_width=2)
4 show(p)
In [ ]: 1