PYTHON PYTHON PYTHON

Python for DataScience

In [1]:
print('Hello')
Hello

$a=b+c$ (did it using $ symbols at the end)

Variables

In [1]:
x = 3
In [2]:
%whos
Variable   Type    Data/Info
----------------------------
x          int     3

Go back

In [3]:
print(type(x))
<class 'int'>
In [4]:
x = 5.07
In [5]:
%whos
Variable   Type     Data/Info
-----------------------------
x          float    5.07
In [6]:
print(type(x))
<class 'float'>
In [7]:
num = 234
In [8]:
%whos
Variable   Type     Data/Info
-----------------------------
num        int      234
x          float    5.07
In [9]:
a,b,c = 34,23.234,-23
In [11]:
whos
Variable   Type     Data/Info
-----------------------------
a          int      34
b          float    23.234
c          int      -23
num        int      234
x          float    5.07
In [12]:
del num
In [13]:
%whos
Variable   Type     Data/Info
-----------------------------
a          int      34
b          float    23.234
c          int      -23
x          float    5.07
In [14]:
c = 2+4j
In [15]:
print(type(c))
<class 'complex'>
In [16]:
word = "HELLOOO"
In [17]:
print(type(word))
<class 'str'>

Operators

In [18]:
2+3
Out[18]:
5
In [19]:
2-3
Out[19]:
-1
In [20]:
6/3
Out[20]:
2.0
In [21]:
6*3
Out[21]:
18
In [22]:
12%5
Out[22]:
2
In [25]:
154//5
Out[25]:
30
In [26]:
2**4
Out[26]:
16
In [27]:
"hello"+" world"
Out[27]:
'hello world'
In [28]:
_  #last non-assigned value
Out[28]:
'hello world'

Bools and Comparisons

In [1]:
a = True
b = False
c = False
In [3]:
%whos
Variable   Type    Data/Info
----------------------------
a          bool    True
b          bool    False
c          bool    False
In [7]:
print(a and b)
print(b and c)
print(a or b)
print(b or c)
not(c)
False
False
True
False
Out[7]:
True

== true if both are equal

!= true if not equal

<,>,<=,>=

In [10]:
  c = (2>3)
  print(type(c))
  print(c)
<class 'bool'>
False

Useful Functions

In [14]:
print(round(4.7889))      #round() function
print(round(4.7889,3))    #argument for number of numbers after decimal
5
4.789
In [17]:
print(divmod(25,2))     #divmod() function . returns back qoutient and remainder
print(divmod(25,7)) 
(12, 1)
(3, 4)
In [23]:
print(isinstance(1,int))    #isinstance() function. checks for condition
print(isinstance(1.0,int))
print(isinstance(1.0,(int,float)))
True
False
True
In [24]:
print(pow(2,3))      #pow() function
print(pow(2,3,3))    #finds power of first two args and finds mod with 3rd argument
8
2
In [ ]:
v = input("Enter a number")#input()
v = float(v)    #changing datatype

Control Flow

In [8]:
print("The largest number will be printed.")
a = int(input("Enter a:  "))
b = int(input("Enter b:  "))
if a>b:
    print(a)
elif a<b:
    print(b)
else:
    print("You entered the same numbers")
The largest number will be printed.
Enter a:  345
Enter b:  345
You entered the same numbers
In [10]:
#if else ,if elif else, nested if,while,for..same as i know

Function def

In [1]:
def prints():
    """prints hi"""
    print("Hiiii")
In [25]:
prints();
Hiiii
In [28]:
#fun(x,y);   supplying variables
In [3]:
#return ___
In [4]:
def add(*args):          #variable number of arguments
    sum = 0
    for i in range(len(args)):
        sum+=args[i]
    return sum
In [7]:
print(add(1,2,3))
6
In [8]:
print(add(234,234,56,35,676))
1235

MODULES

In [25]:
import sys
sys.path.append('/root/Desktop/')
import mymod as mod
from mymod import numeric as num
In [26]:
num(True)
Out[26]:
True

STRING

In [59]:
s = 'abc'
t = "123"
print(type(s))
print(s+" and "+t)
<class 'str'>
abc and 123
In [64]:
ms = '''       hi
        heyy
        heyyyyyyyaaa'''
print(ms)
       hi
        heyy
        heyyyyyyyaaa
In [84]:
a = " Game of Thrones"
print(len(a))

print(a[8:17])
print(a[-7:17])
print(a[-7:])
print(a[0:17:5])
print(a[::-1])

print(a.lower())
print(a.upper())

print(a.strip())

print(a.replace("o","23"))
16
 Thrones
Thrones
Thrones
  hs
senorhT fo emaG 
 game of thrones
 GAME OF THRONES
Game of Thrones
 Game 23f Thr23nes
In [85]:
"abc" in "awgtfrhyjgfds"
Out[85]:
False
In [86]:
"abc" in "abckedfrgtygfdsbac"
Out[86]:
True
In [87]:
"sadfgFDsas" not in "edrftyhugjg"
Out[87]:
True
In [92]:
print("I am \"THE\" hero")
I am "THE" hero
In [93]:
print('I am "THE" hero')
I am "THE" hero
In [98]:
print("C:\name\drive")
print(r"\C:\name\drive")
C:
ame\drive
\C:\name\drive

DATA STRUCTURES

List :ordered changeable duplicates

Tuple :ordered unchangeable duplicates

Set :unordered addable/removable no duplicates

Dictionary :unordered changeable no duplicates

In [106]:
L = [1,3,4,9,"name",8]
T = (1,3,4,9,"name",8)
S = {1,3,4,4,9,"name",8}
D = {23:"twenty-three","t":23,"bcd":"are"}
In [107]:
print(type(L))
print(type(T))
print(type(S))
print(type(D))
<class 'list'>
<class 'tuple'>
<class 'set'>
<class 'dict'>
In [108]:
print(L[3])
print(T[3])
print(3 in S)
print(D[23])
print(D["bcd"])
9
9
True
twenty-three
are
In [110]:
L[1:3]
Out[110]:
[3, 4]
In [111]:
T[1:3]
Out[111]:
(3, 4)
In [115]:
L = L+[12,"AD"]
print(L)
[1, 3, 4, 9, 'name', 8, 12, 'AD', 12, 'AD', 12, 'AD']
In [116]:
L.append(899)
print(L)
[1, 3, 4, 9, 'name', 8, 12, 'AD', 12, 'AD', 12, 'AD', 899]
In [117]:
T2 = (1,3)
In [118]:
T3 = T2 + T
In [119]:
print(T3)
(1, 3, 1, 3, 4, 9, 'name', 8)
In [122]:
S.update({"hiii",234})
print(S)
{'hiii', 1, 'i', 3, 4, 8, 9, 234, 'name', 'h'}
In [123]:
D["neww"] = "NEWWW"
In [124]:
print(D)
{23: 'twenty-three', 't': 23, 'bcd': 'are', 'neww': 'NEWWW'}
In [125]:
D2 = {"hi":123}
In [130]:
L2 =L.copy() #same with set,dictionary
L2
Out[130]:
[1, 3, 4, 9, 'name', 8, 12, 'AD', 12, 'AD', 12, 'AD', 899]
In [132]:
L3 = L[1:5] #slicing picks a copy by default
L3
Out[132]:
[3, 4, 9, 'name']
In [135]:
help(L.append)
Help on built-in function append:

append(object, /) method of builtins.list instance
    Append object to the end of the list.

In [136]:
L4 = [x**4 for x in range(5)]
In [137]:
L4
Out[137]:
[0, 1, 16, 81, 256]

NUMPY

In [4]:
import numpy as np
a = np.array([1,2,3,4,5])
b = np.array((1,2,3,4,5))
print(a)
print(b)
print(type(a))
print(type(b))
[1 2 3 4 5]
[1 2 3 4 5]
<class 'numpy.ndarray'>
<class 'numpy.ndarray'>
In [8]:
c = np.array([234,34,2345],dtype="int")
type(c)
Out[8]:
numpy.ndarray
In [9]:
c.dtype
Out[9]:
dtype('int64')
In [10]:
import numpy as np
a = np.array([[1,2,3],[4,5,6]])
In [11]:
a.ndim
Out[11]:
2
In [12]:
a[0,2]
Out[12]:
3
In [13]:
a[1,2]
Out[13]:
6
In [19]:
b = np.array([[1,2,3,4],[5,6,7,8]])
In [20]:
b.ndim
Out[20]:
2
In [21]:
b[0,3]
Out[21]:
4
In [27]:
c = np.array([[[1,2,3],[4,5,6],[3,4,5]],[[1,-2,3],[4,5,6],[3,4,5]]])
In [24]:
c.ndim
Out[24]:
3
In [28]:
c[1,0,1]
Out[28]:
-2
In [29]:
c.shape
Out[29]:
(2, 3, 3)
In [32]:
print(c.size)
print(c.nbytes)
18
144
In [33]:
d = np.arange(100)
In [34]:
d
Out[34]:
array([ 0,  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])
In [39]:
d = np.arange(0,101)
In [40]:
d
Out[40]:
array([  0,   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])
In [41]:
d = np.arange(0,11,2)
In [42]:
d
Out[42]:
array([ 0,  2,  4,  6,  8, 10])
In [43]:
np.random.permutation(np.arange(10))
Out[43]:
array([8, 1, 0, 6, 9, 4, 3, 5, 7, 2])
In [45]:
np.random.randint(20,300)
Out[45]:
59
In [52]:
f = np.random.rand(100)
In [53]:
print(f)
[2.72814543e-02 6.98736606e-01 7.51684553e-01 1.43020456e-01
 2.43972832e-01 7.43081659e-01 4.28486896e-01 7.22339209e-01
 7.75702226e-01 7.21541326e-01 5.54847086e-01 1.52457341e-01
 7.92902661e-04 7.54461220e-01 2.71556314e-01 9.40975779e-01
 9.18645367e-01 5.62655412e-01 7.39884853e-01 6.49120313e-01
 8.36478030e-01 4.58445398e-01 2.85018227e-01 3.24523753e-01
 5.85261968e-02 7.64834530e-01 5.93698904e-01 1.16488164e-01
 2.88469421e-01 9.74682071e-01 5.62990317e-01 1.70770819e-01
 3.92613908e-01 6.93708904e-01 1.70792275e-01 5.55227883e-01
 7.12563892e-01 9.88453393e-01 3.28589644e-02 1.24641939e-02
 1.26220772e-01 3.76854184e-01 7.60074654e-01 3.45136546e-01
 3.96461484e-01 8.42543293e-01 5.39292548e-01 6.13630127e-02
 3.38004839e-01 8.42455237e-01 5.42894644e-01 7.56480476e-01
 7.85901039e-01 3.61508279e-01 7.28657163e-01 8.93523539e-01
 7.23027373e-01 1.35357630e-01 4.10087946e-01 2.75460993e-01
 9.71366724e-01 5.88382797e-01 6.36789545e-01 6.21759032e-01
 7.80479688e-02 6.46000462e-01 3.82770162e-01 4.63680603e-01
 4.82241074e-01 7.93561241e-01 5.32799451e-01 6.29761689e-01
 6.42307945e-01 6.99345406e-01 8.28689670e-01 4.57487629e-01
 6.80188763e-02 6.81059468e-02 4.92031815e-01 7.41237748e-01
 6.23567911e-01 6.14109290e-03 4.73191516e-01 4.25284111e-01
 3.24357178e-01 1.65801838e-01 2.47342757e-01 6.10337819e-01
 3.51451320e-01 5.42721269e-01 6.71608615e-01 1.85016680e-02
 7.70899352e-01 3.54542712e-01 8.23721330e-01 5.26858645e-01
 5.65731883e-01 1.23418233e-01 3.69760613e-02 2.01674254e-01]
In [54]:
import matplotlib.pyplot as plot
In [56]:
plot.hist(f)
Out[56]:
(array([12.,  9.,  7., 10., 10., 11., 10., 19.,  6.,  6.]),
 array([7.92902661e-04, 9.95589517e-02, 1.98325001e-01, 2.97091050e-01,
        3.95857099e-01, 4.94623148e-01, 5.93389197e-01, 6.92155246e-01,
        7.90921295e-01, 8.89687344e-01, 9.88453393e-01]),
 <a list of 10 Patch objects>)
In [57]:
c = np.random.rand(2,3)
c
Out[57]:
array([[0.31759139, 0.8055908 , 0.72483865],
       [0.56635733, 0.37553939, 0.42952885]])
In [58]:
c.ndim
Out[58]:
2
In [59]:
c = np.random.rand(2,3,4,4)
c
Out[59]:
array([[[[0.43497467, 0.21179162, 0.63957438, 0.69581025],
         [0.04694913, 0.8700612 , 0.19978107, 0.04140946],
         [0.71143631, 0.38852616, 0.1525717 , 0.60583682],
         [0.40301858, 0.87142323, 0.84573101, 0.29135199]],

        [[0.87839067, 0.63813793, 0.15323039, 0.61138039],
         [0.22702349, 0.00369787, 0.72914254, 0.02281479],
         [0.06744226, 0.7857133 , 0.91915463, 0.33438442],
         [0.96328169, 0.27498006, 0.24527254, 0.13292555]],

        [[0.76081672, 0.88209032, 0.00932208, 0.16588378],
         [0.76509286, 0.51846163, 0.62059214, 0.22215307],
         [0.93234503, 0.50563162, 0.07864341, 0.59656455],
         [0.31163042, 0.0360387 , 0.92817203, 0.85190341]]],


       [[[0.33242526, 0.88299117, 0.44898556, 0.57810822],
         [0.0334212 , 0.03056046, 0.67372038, 0.94723535],
         [0.60942801, 0.04928506, 0.29442633, 0.0809329 ],
         [0.62410364, 0.86837606, 0.18923342, 0.92150799]],

        [[0.23218501, 0.54300411, 0.07072959, 0.93602354],
         [0.66350065, 0.14494537, 0.92385323, 0.87602362],
         [0.89896435, 0.4790046 , 0.72868076, 0.98774435],
         [0.28058468, 0.63113385, 0.61441157, 0.70177102]],

        [[0.88025173, 0.58565173, 0.54519874, 0.94255416],
         [0.21870593, 0.00139471, 0.58307469, 0.87482846],
         [0.58725975, 0.29546549, 0.78327705, 0.33651849],
         [0.68495343, 0.66731392, 0.8944574 , 0.63207398]]]])
In [60]:
c.ndim
Out[60]:
4
In [61]:
d = np.arange(100).reshape(4,25)
d
Out[61]:
array([[ 0,  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]])
In [62]:
a = np.arange(100)
b = a[3:10]
print(b)
[3 4 5 6 7 8 9]
In [63]:
b[0] = -10
In [64]:
a
Out[64]:
array([  0,   1,   2, -10,   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])
In [65]:
a[::-5]
Out[65]:
array([99, 94, 89, 84, 79, 74, 69, 64, 59, 54, 49, 44, 39, 34, 29, 24, 19,
       14,  9,  4])
In [66]:
a
Out[66]:
array([  0,   1,   2, -10,   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])
In [67]:
a+12
Out[67]:
array([ 12,  13,  14,   2,  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])
In [68]:
a.sort()
In [69]:
a
Out[69]:
array([-10,   0,   1,   2,   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])
In [3]:
import numpy
b = numpy.random.rand(10000000)
%timeit sum(b)
1.55 s ± 33.9 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
In [5]:
%timeit numpy.sum(b)
5.6 ms ± 28.2 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
In [6]:
def mysum(g):
    s = 0
    for x in g:
        s+=x
    return s
In [7]:
%timeit mysum(b)
1.79 s ± 3.76 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

Pandas

In [9]:
import pandas as pd
In [10]:
A = pd.Series([2,3,4,5],index=['a','b','c','d'])
In [11]:
A.values
Out[11]:
array([2, 3, 4, 5])
In [12]:
type(A.values)
Out[12]:
numpy.ndarray
In [13]:
type(A)
Out[13]:
pandas.core.series.Series
In [14]:
A.index
Out[14]:
Index(['a', 'b', 'c', 'd'], dtype='object')
In [15]:
A['a']
Out[15]:
2
In [16]:
A['a':'c']
Out[16]:
a    2
b    3
c    4
dtype: int64
In [20]:
grades_dict = {"A":4,"B":3,"C":2,"D":1}
grads = pd.Series(grades_dict)
In [21]:
grads.values
Out[21]:
array([4, 3, 2, 1])
In [23]:
marks_dict={"A":80,"B":60,"C":40,"D":20}
marks = pd.Series(marks_dict)
In [24]:
marks
Out[24]:
A    80
B    60
C    40
D    20
dtype: int64
In [25]:
marks.values
Out[25]:
array([80, 60, 40, 20])
In [26]:
marks["A"]
Out[26]:
80
In [27]:
res = pd.DataFrame({'Marks':marks,'Grades':grads})
In [28]:
res
Out[28]:
Marks Grades
A 80 4
B 60 3
C 40 2
D 20 1
In [29]:
res.T
Out[29]:
A B C D
Marks 80 60 40 20
Grades 4 3 2 1
In [31]:
res.values
Out[31]:
array([[80,  4],
       [60,  3],
       [40,  2],
       [20,  1]])
In [32]:
res.values[0,1]
Out[32]:
4
In [35]:
res['Percentage(out of 90)']=100*(res['Marks']/90)
In [36]:
res
Out[36]:
Marks Grades Percentage Percentage(out of 90)
A 80 4 88.888889 88.888889
B 60 3 66.666667 66.666667
C 40 2 44.444444 44.444444
D 20 1 22.222222 22.222222
In [37]:
del res['Percentage']
In [38]:
res
Out[38]:
Marks Grades Percentage(out of 90)
A 80 4 88.888889
B 60 3 66.666667
C 40 2 44.444444
D 20 1 22.222222
In [41]:
g = res[res['Marks']>60]
In [42]:
g
Out[42]:
Marks Grades Percentage(out of 90)
A 80 4 88.888889
In [43]:
z = pd.DataFrame([{'a':1,'b':2},{'b':3,'c':4}])
In [44]:
z
Out[44]:
a b c
0 1.0 2 NaN
1 NaN 3 4.0
In [45]:
z.T
Out[45]:
0 1
a 1.0 NaN
b 2.0 3.0
c NaN 4.0
In [47]:
z.fillna(0)
Out[47]:
a b c
0 1.0 2 0.0
1 0.0 3 4.0
In [50]:
z.dropna()  #drops all rows which has na
Out[50]:
a b c
In [52]:
z
Out[52]:
a b c
0 1.0 2 NaN
1 NaN 3 4.0
In [55]:
a = pd.Series(['a','b','c'],index=[1,3,5])
In [56]:
a[1]
Out[56]:
'a'
In [57]:
a[1:3]
Out[57]:
3    b
5    c
dtype: object
In [58]:
a.loc[1:3]
Out[58]:
1    a
3    b
dtype: object
In [59]:
a.iloc[1:3]
Out[59]:
3    b
5    c
dtype: object
In [62]:
#pd.read_csv('path')
#df.head(n)
#df.drop(['Sno',..],axis=1,inaplce=True)
#df.rename(columns={'ObservationDAte':'Date'},inaplce=True)
#df.info
#df.fillna(NA)
#df.groupby('')
In [64]:
import matplotlib.pyplot as plt
import numpy as np
In [66]:
x = np.linspace(0,10,1000)
print(x)
plt.plot(x,np.sin(x));
[ 0.          0.01001001  0.02002002  0.03003003  0.04004004  0.05005005
  0.06006006  0.07007007  0.08008008  0.09009009  0.1001001   0.11011011
  0.12012012  0.13013013  0.14014014  0.15015015  0.16016016  0.17017017
  0.18018018  0.19019019  0.2002002   0.21021021  0.22022022  0.23023023
  0.24024024  0.25025025  0.26026026  0.27027027  0.28028028  0.29029029
  0.3003003   0.31031031  0.32032032  0.33033033  0.34034034  0.35035035
  0.36036036  0.37037037  0.38038038  0.39039039  0.4004004   0.41041041
  0.42042042  0.43043043  0.44044044  0.45045045  0.46046046  0.47047047
  0.48048048  0.49049049  0.5005005   0.51051051  0.52052052  0.53053053
  0.54054054  0.55055055  0.56056056  0.57057057  0.58058058  0.59059059
  0.6006006   0.61061061  0.62062062  0.63063063  0.64064064  0.65065065
  0.66066066  0.67067067  0.68068068  0.69069069  0.7007007   0.71071071
  0.72072072  0.73073073  0.74074074  0.75075075  0.76076076  0.77077077
  0.78078078  0.79079079  0.8008008   0.81081081  0.82082082  0.83083083
  0.84084084  0.85085085  0.86086086  0.87087087  0.88088088  0.89089089
  0.9009009   0.91091091  0.92092092  0.93093093  0.94094094  0.95095095
  0.96096096  0.97097097  0.98098098  0.99099099  1.001001    1.01101101
  1.02102102  1.03103103  1.04104104  1.05105105  1.06106106  1.07107107
  1.08108108  1.09109109  1.1011011   1.11111111  1.12112112  1.13113113
  1.14114114  1.15115115  1.16116116  1.17117117  1.18118118  1.19119119
  1.2012012   1.21121121  1.22122122  1.23123123  1.24124124  1.25125125
  1.26126126  1.27127127  1.28128128  1.29129129  1.3013013   1.31131131
  1.32132132  1.33133133  1.34134134  1.35135135  1.36136136  1.37137137
  1.38138138  1.39139139  1.4014014   1.41141141  1.42142142  1.43143143
  1.44144144  1.45145145  1.46146146  1.47147147  1.48148148  1.49149149
  1.5015015   1.51151151  1.52152152  1.53153153  1.54154154  1.55155155
  1.56156156  1.57157157  1.58158158  1.59159159  1.6016016   1.61161161
  1.62162162  1.63163163  1.64164164  1.65165165  1.66166166  1.67167167
  1.68168168  1.69169169  1.7017017   1.71171171  1.72172172  1.73173173
  1.74174174  1.75175175  1.76176176  1.77177177  1.78178178  1.79179179
  1.8018018   1.81181181  1.82182182  1.83183183  1.84184184  1.85185185
  1.86186186  1.87187187  1.88188188  1.89189189  1.9019019   1.91191191
  1.92192192  1.93193193  1.94194194  1.95195195  1.96196196  1.97197197
  1.98198198  1.99199199  2.002002    2.01201201  2.02202202  2.03203203
  2.04204204  2.05205205  2.06206206  2.07207207  2.08208208  2.09209209
  2.1021021   2.11211211  2.12212212  2.13213213  2.14214214  2.15215215
  2.16216216  2.17217217  2.18218218  2.19219219  2.2022022   2.21221221
  2.22222222  2.23223223  2.24224224  2.25225225  2.26226226  2.27227227
  2.28228228  2.29229229  2.3023023   2.31231231  2.32232232  2.33233233
  2.34234234  2.35235235  2.36236236  2.37237237  2.38238238  2.39239239
  2.4024024   2.41241241  2.42242242  2.43243243  2.44244244  2.45245245
  2.46246246  2.47247247  2.48248248  2.49249249  2.5025025   2.51251251
  2.52252252  2.53253253  2.54254254  2.55255255  2.56256256  2.57257257
  2.58258258  2.59259259  2.6026026   2.61261261  2.62262262  2.63263263
  2.64264264  2.65265265  2.66266266  2.67267267  2.68268268  2.69269269
  2.7027027   2.71271271  2.72272272  2.73273273  2.74274274  2.75275275
  2.76276276  2.77277277  2.78278278  2.79279279  2.8028028   2.81281281
  2.82282282  2.83283283  2.84284284  2.85285285  2.86286286  2.87287287
  2.88288288  2.89289289  2.9029029   2.91291291  2.92292292  2.93293293
  2.94294294  2.95295295  2.96296296  2.97297297  2.98298298  2.99299299
  3.003003    3.01301301  3.02302302  3.03303303  3.04304304  3.05305305
  3.06306306  3.07307307  3.08308308  3.09309309  3.1031031   3.11311311
  3.12312312  3.13313313  3.14314314  3.15315315  3.16316316  3.17317317
  3.18318318  3.19319319  3.2032032   3.21321321  3.22322322  3.23323323
  3.24324324  3.25325325  3.26326326  3.27327327  3.28328328  3.29329329
  3.3033033   3.31331331  3.32332332  3.33333333  3.34334334  3.35335335
  3.36336336  3.37337337  3.38338338  3.39339339  3.4034034   3.41341341
  3.42342342  3.43343343  3.44344344  3.45345345  3.46346346  3.47347347
  3.48348348  3.49349349  3.5035035   3.51351351  3.52352352  3.53353353
  3.54354354  3.55355355  3.56356356  3.57357357  3.58358358  3.59359359
  3.6036036   3.61361361  3.62362362  3.63363363  3.64364364  3.65365365
  3.66366366  3.67367367  3.68368368  3.69369369  3.7037037   3.71371371
  3.72372372  3.73373373  3.74374374  3.75375375  3.76376376  3.77377377
  3.78378378  3.79379379  3.8038038   3.81381381  3.82382382  3.83383383
  3.84384384  3.85385385  3.86386386  3.87387387  3.88388388  3.89389389
  3.9039039   3.91391391  3.92392392  3.93393393  3.94394394  3.95395395
  3.96396396  3.97397397  3.98398398  3.99399399  4.004004    4.01401401
  4.02402402  4.03403403  4.04404404  4.05405405  4.06406406  4.07407407
  4.08408408  4.09409409  4.1041041   4.11411411  4.12412412  4.13413413
  4.14414414  4.15415415  4.16416416  4.17417417  4.18418418  4.19419419
  4.2042042   4.21421421  4.22422422  4.23423423  4.24424424  4.25425425
  4.26426426  4.27427427  4.28428428  4.29429429  4.3043043   4.31431431
  4.32432432  4.33433433  4.34434434  4.35435435  4.36436436  4.37437437
  4.38438438  4.39439439  4.4044044   4.41441441  4.42442442  4.43443443
  4.44444444  4.45445445  4.46446446  4.47447447  4.48448448  4.49449449
  4.5045045   4.51451451  4.52452452  4.53453453  4.54454454  4.55455455
  4.56456456  4.57457457  4.58458458  4.59459459  4.6046046   4.61461461
  4.62462462  4.63463463  4.64464464  4.65465465  4.66466466  4.67467467
  4.68468468  4.69469469  4.7047047   4.71471471  4.72472472  4.73473473
  4.74474474  4.75475475  4.76476476  4.77477477  4.78478478  4.79479479
  4.8048048   4.81481481  4.82482482  4.83483483  4.84484484  4.85485485
  4.86486486  4.87487487  4.88488488  4.89489489  4.9049049   4.91491491
  4.92492492  4.93493493  4.94494494  4.95495495  4.96496496  4.97497497
  4.98498498  4.99499499  5.00500501  5.01501502  5.02502503  5.03503504
  5.04504505  5.05505506  5.06506507  5.07507508  5.08508509  5.0950951
  5.10510511  5.11511512  5.12512513  5.13513514  5.14514515  5.15515516
  5.16516517  5.17517518  5.18518519  5.1951952   5.20520521  5.21521522
  5.22522523  5.23523524  5.24524525  5.25525526  5.26526527  5.27527528
  5.28528529  5.2952953   5.30530531  5.31531532  5.32532533  5.33533534
  5.34534535  5.35535536  5.36536537  5.37537538  5.38538539  5.3953954
  5.40540541  5.41541542  5.42542543  5.43543544  5.44544545  5.45545546
  5.46546547  5.47547548  5.48548549  5.4954955   5.50550551  5.51551552
  5.52552553  5.53553554  5.54554555  5.55555556  5.56556557  5.57557558
  5.58558559  5.5955956   5.60560561  5.61561562  5.62562563  5.63563564
  5.64564565  5.65565566  5.66566567  5.67567568  5.68568569  5.6956957
  5.70570571  5.71571572  5.72572573  5.73573574  5.74574575  5.75575576
  5.76576577  5.77577578  5.78578579  5.7957958   5.80580581  5.81581582
  5.82582583  5.83583584  5.84584585  5.85585586  5.86586587  5.87587588
  5.88588589  5.8958959   5.90590591  5.91591592  5.92592593  5.93593594
  5.94594595  5.95595596  5.96596597  5.97597598  5.98598599  5.995996
  6.00600601  6.01601602  6.02602603  6.03603604  6.04604605  6.05605606
  6.06606607  6.07607608  6.08608609  6.0960961   6.10610611  6.11611612
  6.12612613  6.13613614  6.14614615  6.15615616  6.16616617  6.17617618
  6.18618619  6.1961962   6.20620621  6.21621622  6.22622623  6.23623624
  6.24624625  6.25625626  6.26626627  6.27627628  6.28628629  6.2962963
  6.30630631  6.31631632  6.32632633  6.33633634  6.34634635  6.35635636
  6.36636637  6.37637638  6.38638639  6.3963964   6.40640641  6.41641642
  6.42642643  6.43643644  6.44644645  6.45645646  6.46646647  6.47647648
  6.48648649  6.4964965   6.50650651  6.51651652  6.52652653  6.53653654
  6.54654655  6.55655656  6.56656657  6.57657658  6.58658659  6.5965966
  6.60660661  6.61661662  6.62662663  6.63663664  6.64664665  6.65665666
  6.66666667  6.67667668  6.68668669  6.6966967   6.70670671  6.71671672
  6.72672673  6.73673674  6.74674675  6.75675676  6.76676677  6.77677678
  6.78678679  6.7967968   6.80680681  6.81681682  6.82682683  6.83683684
  6.84684685  6.85685686  6.86686687  6.87687688  6.88688689  6.8968969
  6.90690691  6.91691692  6.92692693  6.93693694  6.94694695  6.95695696
  6.96696697  6.97697698  6.98698699  6.996997    7.00700701  7.01701702
  7.02702703  7.03703704  7.04704705  7.05705706  7.06706707  7.07707708
  7.08708709  7.0970971   7.10710711  7.11711712  7.12712713  7.13713714
  7.14714715  7.15715716  7.16716717  7.17717718  7.18718719  7.1971972
  7.20720721  7.21721722  7.22722723  7.23723724  7.24724725  7.25725726
  7.26726727  7.27727728  7.28728729  7.2972973   7.30730731  7.31731732
  7.32732733  7.33733734  7.34734735  7.35735736  7.36736737  7.37737738
  7.38738739  7.3973974   7.40740741  7.41741742  7.42742743  7.43743744
  7.44744745  7.45745746  7.46746747  7.47747748  7.48748749  7.4974975
  7.50750751  7.51751752  7.52752753  7.53753754  7.54754755  7.55755756
  7.56756757  7.57757758  7.58758759  7.5975976   7.60760761  7.61761762
  7.62762763  7.63763764  7.64764765  7.65765766  7.66766767  7.67767768
  7.68768769  7.6976977   7.70770771  7.71771772  7.72772773  7.73773774
  7.74774775  7.75775776  7.76776777  7.77777778  7.78778779  7.7977978
  7.80780781  7.81781782  7.82782783  7.83783784  7.84784785  7.85785786
  7.86786787  7.87787788  7.88788789  7.8978979   7.90790791  7.91791792
  7.92792793  7.93793794  7.94794795  7.95795796  7.96796797  7.97797798
  7.98798799  7.997998    8.00800801  8.01801802  8.02802803  8.03803804
  8.04804805  8.05805806  8.06806807  8.07807808  8.08808809  8.0980981
  8.10810811  8.11811812  8.12812813  8.13813814  8.14814815  8.15815816
  8.16816817  8.17817818  8.18818819  8.1981982   8.20820821  8.21821822
  8.22822823  8.23823824  8.24824825  8.25825826  8.26826827  8.27827828
  8.28828829  8.2982983   8.30830831  8.31831832  8.32832833  8.33833834
  8.34834835  8.35835836  8.36836837  8.37837838  8.38838839  8.3983984
  8.40840841  8.41841842  8.42842843  8.43843844  8.44844845  8.45845846
  8.46846847  8.47847848  8.48848849  8.4984985   8.50850851  8.51851852
  8.52852853  8.53853854  8.54854855  8.55855856  8.56856857  8.57857858
  8.58858859  8.5985986   8.60860861  8.61861862  8.62862863  8.63863864
  8.64864865  8.65865866  8.66866867  8.67867868  8.68868869  8.6986987
  8.70870871  8.71871872  8.72872873  8.73873874  8.74874875  8.75875876
  8.76876877  8.77877878  8.78878879  8.7987988   8.80880881  8.81881882
  8.82882883  8.83883884  8.84884885  8.85885886  8.86886887  8.87887888
  8.88888889  8.8988989   8.90890891  8.91891892  8.92892893  8.93893894
  8.94894895  8.95895896  8.96896897  8.97897898  8.98898899  8.998999
  9.00900901  9.01901902  9.02902903  9.03903904  9.04904905  9.05905906
  9.06906907  9.07907908  9.08908909  9.0990991   9.10910911  9.11911912
  9.12912913  9.13913914  9.14914915  9.15915916  9.16916917  9.17917918
  9.18918919  9.1991992   9.20920921  9.21921922  9.22922923  9.23923924
  9.24924925  9.25925926  9.26926927  9.27927928  9.28928929  9.2992993
  9.30930931  9.31931932  9.32932933  9.33933934  9.34934935  9.35935936
  9.36936937  9.37937938  9.38938939  9.3993994   9.40940941  9.41941942
  9.42942943  9.43943944  9.44944945  9.45945946  9.46946947  9.47947948
  9.48948949  9.4994995   9.50950951  9.51951952  9.52952953  9.53953954
  9.54954955  9.55955956  9.56956957  9.57957958  9.58958959  9.5995996
  9.60960961  9.61961962  9.62962963  9.63963964  9.64964965  9.65965966
  9.66966967  9.67967968  9.68968969  9.6996997   9.70970971  9.71971972
  9.72972973  9.73973974  9.74974975  9.75975976  9.76976977  9.77977978
  9.78978979  9.7997998   9.80980981  9.81981982  9.82982983  9.83983984
  9.84984985  9.85985986  9.86986987  9.87987988  9.88988989  9.8998999
  9.90990991  9.91991992  9.92992993  9.93993994  9.94994995  9.95995996
  9.96996997  9.97997998  9.98998999 10.        ]
In [69]:
plt.scatter(x[::10],np.sin(x)[::10],color='red')
Out[69]:
<matplotlib.collections.PathCollection at 0x7f1b76c23520>
In [ ]: