<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Python on Alok Regmi</title>
		<link>https://alokregmi.com/tags/python/</link>
		<description>Recent content in Python on Alok Regmi</description>
		<generator>Hugo</generator>
		<language>en-us</language>
		
		
		
		
			<lastBuildDate>Sun, 18 Oct 2020 07:12:40 +0545</lastBuildDate>
		
			<atom:link href="https://alokregmi.com/tags/python/index.xml" rel="self" type="application/rss+xml" />
			<item>
				<title>Numpy</title>
				<link>https://alokregmi.com/braindump/2020/04/numpy/</link>
				<pubDate>Sun, 19 Apr 2020 16:00:50 +0545</pubDate>
				<guid>https://alokregmi.com/braindump/2020/04/numpy/</guid>
				<description>&lt;h2 id=&#34;working-with-numpy&#34;&gt;Working with numpy:&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;import numpy as np&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;a = np.array([0,1,2])&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;a.ndim - gives dimension of array&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;a.shape : gives the shape of the array&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;a.reshape((3,2)) new order of matrix to be formed&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;changing a element of an array we reshaped is also going to change from the original since numpy package avoids copies&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;so if copy needed: c= a.reshape((3,2)).copy()&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Contrast to general array operations:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;a*2 multiplies each element by 2&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;alok &amp;gt;4&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;alok[alok&amp;gt;4] trim out using a condition for the array&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;alok.clip(0,4) clipping the data between the range with both ends taken into consideration&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Handle non existing values:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;c= np.array([1,2,np.NAN,3])&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;np.isnan(c) return true false on the basis of the data element in array is number or not&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;c[~np.isnan(c)] remove nan&amp;rsquo;s from the array&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;np.mean(c[~np.isnan(c)]) calculate the mean of the data feed that are only numbers&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;use of dot functions for numpy speeds by almost 25 times the average naive numpy rate&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;by taking list items, numpy auto makes the best possible common datatype for those members&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;</description>
			</item>
			<item>
				<title>Scipy</title>
				<link>https://alokregmi.com/braindump/2020/04/scipy/</link>
				<pubDate>Sun, 19 Apr 2020 16:00:31 +0545</pubDate>
				<guid>https://alokregmi.com/braindump/2020/04/scipy/</guid>
				<description>&lt;p&gt;In python lists copies the elements twice and power is not applicable but for numpy arrays we can directly use the power function&#xA;a*2 means multiply each element by 2&#xA;a**2 means square of each term on the array&lt;/p&gt;&#xA;&lt;p&gt;import matplotlib.pyplot as plt&#xA;plt.scatter(x,y)&#xA;plt.title(&amp;ldquo;Web traffic over the last month&amp;rdquo;)&#xA;plt.xlabel(&amp;ldquo;Time&amp;rdquo;)&#xA;plt.ylabel(&amp;ldquo;Hits/hour&amp;rdquo;)&#xA;plt.xticks([w*7*24 for w in range(10)],&#xA;[&amp;lsquo;week %i&amp;rsquo;%w for w in range(10)])&#xA;plt.autoscale(tight=True)&#xA;plt.grid()&#xA;plt.show()&lt;/p&gt;</description>
			</item>
			<item>
				<title>Python one liners</title>
				<link>https://alokregmi.com/braindump/2020/04/python-one-liners/</link>
				<pubDate>Sun, 19 Apr 2020 16:00:25 +0545</pubDate>
				<guid>https://alokregmi.com/braindump/2020/04/python-one-liners/</guid>
				<description>&lt;p&gt;print(sum(map(int,bin(int(input()))[2:]))) : Adding numbers from a number converted to binary&lt;/p&gt;</description>
			</item>
			<item>
				<title>Python</title>
				<link>https://alokregmi.com/braindump/2020/04/python/</link>
				<pubDate>Sun, 19 Apr 2020 15:59:54 +0545</pubDate>
				<guid>https://alokregmi.com/braindump/2020/04/python/</guid>
				<description>&lt;p&gt;&amp;ndash; iteration:&#xA;-! specific no of times: range(5)&#xA;-! as long as the variable : for ch in &amp;ldquo;Hello&amp;rdquo;&#xA;&amp;ndash; querying the directory of the module for objects to use:&#xA;e.g. import random&#xA;dir(random)&#xA;&amp;ndash; asking for help with the object we searched:&#xA;help(random.randint)&#xA;&amp;ndash; sleep function:&#xA;import time&#xA;time.sleep(5)&#xA;&amp;ndash; Know that everything is an object in python&#xA;&amp;ndash; Built in data structures: list, dictionary, tuple and sets&#xA;-! lists are dynamic and mutable too.&#xA;-! methods: append() , len(list_name), remove(item_name),pop(index),pop()-last element removed&#xA;-! methods: extend([3,4]),insert(index,item),pop() returns the removed value&#xA;-! copying using assignment is not actual. it just points to the same thing.&#xA;first = [1,2,4]&#xA;second = first&#xA;first.append(5)&lt;/p&gt;</description>
			</item>
			<item>
				<title>Matplotlib</title>
				<link>https://alokregmi.com/braindump/2020/04/matplotlib/</link>
				<pubDate>Sun, 19 Apr 2020 15:59:45 +0545</pubDate>
				<guid>https://alokregmi.com/braindump/2020/04/matplotlib/</guid>
				<description>&lt;p&gt;triangles&lt;/p&gt;&#xA;&lt;p&gt;plot(t, t, &amp;lsquo;r&amp;ndash;&amp;rsquo;, t, t**2, &amp;lsquo;bs&amp;rsquo;, t, t**3, &amp;lsquo;g^&amp;rsquo;)&lt;/p&gt;&#xA;&lt;p&gt;plt.plot(x,y,&amp;lsquo;r&amp;ndash;&amp;rsquo;, linewidth=1.0)&lt;/p&gt;&#xA;&lt;p&gt;when lines= plt.plot(x1,y1,x2,y2)&lt;/p&gt;&#xA;&lt;p&gt;and the use of subplot() command&lt;/p&gt;&#xA;&lt;p&gt;plt.figure(1)                # the first figure&#xA;plt.subplot(211)             # the first subplot in the first figure&#xA;plt.plot([1, 2, 3])&#xA;plt.subplot(212)             # the second subplot in the first figure&#xA;plt.plot([4, 5, 6])&lt;/p&gt;&#xA;&lt;p&gt;plt.figure(2)                # a second figure&#xA;plt.plot([4, 5, 6])          # creates a subplot(111) by default&lt;/p&gt;&#xA;&lt;p&gt;plt.figure(1)                # figure 1 current; subplot(212) still current&#xA;plt.subplot(211)             # make subplot(211) in figure1 current&#xA;plt.title(&amp;lsquo;Easy as 1, 2, 3&amp;rsquo;)&lt;/p&gt;</description>
			</item>
			<item>
				<title>Django Process</title>
				<link>https://alokregmi.com/braindump/2020/04/django-process/</link>
				<pubDate>Sun, 19 Apr 2020 15:58:59 +0545</pubDate>
				<guid>https://alokregmi.com/braindump/2020/04/django-process/</guid>
				<description>&lt;p&gt;FIrst i created project, then created an app&#xA;Registered the app into the setttings.py file&#xA;Then first created the view in the app, then add url to the urls.py file in the app&#xA;If more urls are to be added and multiple apps within the project use include and make urls.py in own app&#xA;Then made the html file in index directory and worked there.&#xA;The function in views class takes the request as parameter and returns either HttpResponse or a render&#xA;object.&#xA;Render or render_to_response are somehow similar  and we give them the request, the file to open i.e. html file and then the variables to be sent with {&amp;ldquo;temp_name&amp;rdquo;: my_var}.&#xA;We edit the html file by putting in the variables as {{ temp_name }} and this works.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Anaconda Windows</title>
				<link>https://alokregmi.com/ai/anaconda-windows/</link>
				<pubDate>Mon, 03 Feb 2020 00:00:00 +0000</pubDate>
				<guid>https://alokregmi.com/ai/anaconda-windows/</guid>
				<description>&lt;h2 id=&#34;anaconda-installation-in-windows&#34;&gt;Anaconda Installation in Windows&lt;/h2&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Issue with pyzmq:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   pip uninstall pyzmq&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   pip install pyzmq&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Issue with requests&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   conda deactivate&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   conda update --force conda&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Issue with sqlite3&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Find sqlite 3 dll&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://www.sqlite.org/download.html&#34;&gt;https://www.sqlite.org/download.html&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Put it into &lt;em&gt;Anaconda3/DLLS/&lt;/em&gt; folder&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Install Python 3.6 or 3.7 if you want same env for PyTorch as well as for&#xA;working with TensorFlow-GPU.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Anaconda if HTTPS error:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   conda --config ssl_verify&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;false&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Path variable has importance of order. Based on which python you want as&#xA;default, put that higher in PATH variable list in windows.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;To install notebook:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;just do pip install notebook&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;conda list command : same as pip freeze : shows who installed it conda or pip&#xA;as well as the versions.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;</description>
			</item>
			<item>
				<title>Matplotlib</title>
				<link>https://alokregmi.com/ai/matplotlib/</link>
				<pubDate>Fri, 27 Dec 2019 00:00:00 +0000</pubDate>
				<guid>https://alokregmi.com/ai/matplotlib/</guid>
				<description>&lt;h2 id=&#34;matplotlib&#34;&gt;Matplotlib&lt;/h2&gt;&#xA;&lt;h3 id=&#34;creating-objects-for-interaction&#34;&gt;Creating objects for interaction&lt;/h3&gt;&#xA;&lt;!--list-separator--&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Create empty plot to be filled in with data&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code class=&#34;language-jupyter-python&#34; data-lang=&#34;jupyter-python&#34;&gt;import matplotlib.pyplot as plt&#xA;fig, ax = plt.subplots()&#xA;plt.show()&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;!--list-separator--&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Create some plot&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code class=&#34;language-jupyter-python&#34; data-lang=&#34;jupyter-python&#34;&gt;from sklearn import datasets&#xA;import pandas as pd&#xA;import numpy as np&#xA;iris = datasets.load_iris()&#xA;df = pd.DataFrame(data= np.c_[iris[&amp;#39;data&amp;#39;], iris[&amp;#39;target&amp;#39;]],&#xA;                     columns= iris[&amp;#39;feature_names&amp;#39;] + [&amp;#39;target&amp;#39;])&#xA;print(df.head())&#xA;&#xA;import matplotlib.pyplot as plt&#xA;fig, ax = plt.subplots()&#xA;ax.plot(df.iloc[:,0], df.iloc[:,1])&#xA;plt.show()&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   sepal length (cm)  sepal width (cm)  petal length (cm)  petal width (cm)  \&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;0                5.1               3.5                1.4               0.2&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;1                4.9               3.0                1.4               0.2&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;2                4.7               3.2                1.3               0.2&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;3                4.6               3.1                1.5               0.2&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;4                5.0               3.6                1.4               0.2&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   target&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;0     0.0&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;1     0.0&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;2     0.0&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;3     0.0&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;4     0.0&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;figure&gt;&lt;img src=&#34;../../ox-hugo/d4f1d991e8d2e5142059b8cc6dcfd1f5b827e08c.png&#34;&gt;&#xA;    &lt;/figure&gt;&#xA;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3 id=&#34;other-functionalities&#34;&gt;Other functionalities&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;plt.axis([x-axis_start, xend, ystart, yend])&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;plt.plot(x,y,&amp;lsquo;color or dots or any fucking thing to represent the numbers&amp;rsquo;)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;r&amp;ndash; means red dashes and bs means blue squares and g^ means green&#xA;triangles&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;make a numpy array using arange(start, end, step_size)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;multiple plot in plot()&#xA;plot(t, t, &amp;lsquo;r&amp;ndash;&amp;rsquo;, t, t**2, &amp;lsquo;bs&amp;rsquo;, t, t**3, &amp;lsquo;g^&amp;rsquo;)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;tuple unpacking with obj_name, comma  is the essence&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;setting linewidth with:&#xA;plt.plot(x,y,&amp;lsquo;r&amp;ndash;&amp;rsquo;, linewidth=1.0)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;plt.setp(lines, color=&amp;lsquo;r&amp;rsquo;, linewidth=2.0)&#xA;when lines= plt.plot(x1,y1,x2,y2)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;plt.plot(t1, f(t1), &amp;lsquo;bo&amp;rsquo;, t2, f(t2), &amp;lsquo;k&amp;rsquo;)&#xA;and the use of subplot() command&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;plt.figure(fig_no)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;using figures and subplot()&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;</description>
			</item>
			<item>
				<title>Scipy</title>
				<link>https://alokregmi.com/ai/scipy/</link>
				<pubDate>Sun, 08 Dec 2019 00:00:00 +0000</pubDate>
				<guid>https://alokregmi.com/ai/scipy/</guid>
				<description>&lt;h2 id=&#34;scipy-tips&#34;&gt;Scipy Tips&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;In python lists copies the elements twice and power is not applicable but for numpy arrays we can directly use the power function&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;a*2 means multiply each element by 2&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;a**2 means square of each term on the array&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;a[a&amp;gt;4] = 4 assigns the element with value greater than 4 to 4&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;a.clip(0,1) makes the elements of the array that are greater than 1 to 1&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Can handle non existing values too..  and also can check is.whatever_the_specification&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;can remove such values as well a[~np.nan(a)]&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;numpy cannot hold any type of data as the python lists do .dtype is fixed&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;sp.genfromtext(&amp;ldquo;path&amp;rdquo;, delimiter=&amp;quot;\t&amp;quot;)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;sp.sum(sp.isnan(y)) where y contains one d data&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;</description>
			</item>
			<item>
				<title>Numpy</title>
				<link>https://alokregmi.com/ai/numpy/</link>
				<pubDate>Mon, 02 Dec 2019 00:00:00 +0000</pubDate>
				<guid>https://alokregmi.com/ai/numpy/</guid>
				<description>&lt;h2 id=&#34;working-with-numpy&#34;&gt;Working with numpy:&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;import numpy as np&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;a = np.array([0,1,2])&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;a.ndim - gives dimension of array&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;a.shape : gives the shape of the array&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;a.reshape((3,2)) new order of matrix to be formed&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;changing a element of an array we reshaped is also going to change from the original since numpy package avoids copies&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;so if copy needed: c= a.reshape((3,2)).copy()&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Contrast to general array operations:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;a*2 multiplies each element by 2&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;alok &amp;gt;4&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;alok[alok&amp;gt;4] trim out using a condition for the array&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;alok.clip(0,4) clipping the data between the range with both ends taken into consideration&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Handle non existing values:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;c= np.array([1,2,np.NAN,3])&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;np.isnan(c) return true false on the basis of the data element in array is number or not&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;c[~np.isnan(c)] remove nan&amp;rsquo;s from the array&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;np.mean(c[~np.isnan(c)]) calculate the mean of the data feed that are only numbers&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;use of dot functions for numpy speeds by almost 25 times the average naive numpy rate&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;by taking list items, numpy auto makes the best possible common datatype for those members&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;</description>
			</item>
	</channel>
</rss>
