<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Ask Ghassem - Recent questions tagged python</title>
<link>https://ask.ghassem.com/tag/python</link>
<description>Powered by Question2Answer</description>
<item>
<title>Which code has best runtime and why?(the one commented or the other one)</title>
<link>https://ask.ghassem.com/1027/which-code-has-best-runtime-and-why-the-one-commented-the-other</link>
<description># for key, value in dict.items():&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;# &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if value &amp;gt;= long:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;# &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;long = value&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;# &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;long_name = key&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;# &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if value &amp;lt; short:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;# &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;short = value&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;# &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;short_name = key&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;long = max(dict.values())&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;long_name = max(dict, key=dict.get)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;short = min(dict.values())&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;short_name = min(dict, key=dict.get)</description>
<category>Python</category>
<guid isPermaLink="true">https://ask.ghassem.com/1027/which-code-has-best-runtime-and-why-the-one-commented-the-other</guid>
<pubDate>Fri, 02 Sep 2022 14:39:49 +0000</pubDate>
</item>
<item>
<title>Kmeans clustering in python - Giving original labels to predicted clusters</title>
<link>https://ask.ghassem.com/1022/kmeans-clustering-python-giving-original-predicted-clusters</link>
<description>&lt;p&gt;I have a dataset with 7 labels in the target variable.&lt;/p&gt;

&lt;pre class=&quot;prettyprint lang-python&quot; data-pbcklang=&quot;python&quot; data-pbcktabsize=&quot;4&quot;&gt;
X = data.drop(&#039;target&#039;, axis=1)
Y = data[&#039;target&#039;]
Y.unique()&lt;/pre&gt;

&lt;p&gt;array([&#039;Normal_Weight&#039;, &#039;Overweight_Level_I&#039;, &#039;Overweight_Level_II&#039;,&lt;br&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&#039;Obesity_Type_I&#039;, &#039;Insufficient_Weight&#039;, &#039;Obesity_Type_II&#039;,&lt;br&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&#039;Obesity_Type_III&#039;], dtype=object)&lt;/p&gt;

&lt;pre class=&quot;prettyprint lang-python&quot; data-pbcklang=&quot;python&quot; data-pbcktabsize=&quot;4&quot;&gt;
km = KMeans(n_clusters=7, init=&quot;k-means++&quot;, random_state=300)
km.fit_predict(X)
np.unique(km.labels_)&lt;/pre&gt;

&lt;p&gt;array([0, 1, 2, 3, 4, 5, 6])&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;After performing KMean clustering algorithm with number of clusters as 7, the resulted clusters are labeled as 0,1,2,3,4,5,6. But how to know which real label matches with the predicted label.&lt;/p&gt;

&lt;p&gt;In other words, I want to know how to give original label names to new predicted labels, so that they can be compared like how many values are clustered correctly (Accuracy).&lt;/p&gt;</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/1022/kmeans-clustering-python-giving-original-predicted-clusters</guid>
<pubDate>Wed, 27 Apr 2022 05:32:54 +0000</pubDate>
</item>
<item>
<title>ValueError: Length mismatch: Expected axis has 60 elements, new values have 2935849 elements</title>
<link>https://ask.ghassem.com/1005/valueerror-length-mismatch-expected-elements-2935849-elements</link>
<description>&lt;p&gt;I&#039;m creating a new data frame&amp;nbsp;with the most used items grouped together. But I got the following error when grouping through ID and items.&amp;nbsp;ValueError: Length mismatch: Expected axis has 60 elements, new values have 2935849 elements.&lt;/p&gt;

&lt;pre class=&quot;prettyprint lang-python&quot; data-pbcklang=&quot;python&quot; data-pbcktabsize=&quot;4&quot;&gt;
df = sales_df[sales_df[&#039;shop_id&#039;].duplicated(keep=False)]
df[&#039;Grouped&#039;] = sales_df.groupby(&#039;shop_id&#039;)[&#039;item_name&#039;].transform(lambda x: &#039;,&#039;.join(x))
df2 = df[[&#039;shop_id&#039;, &#039;Grouped&#039;]].drop_duplicates()&lt;/pre&gt;

&lt;p&gt;In the aforementioned code, I&#039;m making a data frame with respect to shop id and then grouping through shop items. My objective here is to group items with similar ID.&lt;/p&gt;</description>
<category>Exploratory Data Analysis</category>
<guid isPermaLink="true">https://ask.ghassem.com/1005/valueerror-length-mismatch-expected-elements-2935849-elements</guid>
<pubDate>Fri, 26 Nov 2021 06:09:16 +0000</pubDate>
</item>
<item>
<title>Can Data Science solve this problem?</title>
<link>https://ask.ghassem.com/1002/can-data-science-solve-this-problem</link>
<description>So, I live in Brazil, and I have a task for college that I don&amp;#039;t know what data science method to use, if at all, to solve it. My idea is the following: We Brazilians have Real (BRL) as currency, and we of course have the dollar quotation value to see &amp;quot;how many Reais a dollar is worth&amp;quot;. What I wanted to do was to make a research and see whether the Country News have any influence over this price. So for example, if Bolsonaro, our president, says some dumb stuff, the dollar got up in price, and vice versa. What I wanted to do was collect all dollar values and variance over a set time interval, and try and get webscraping to get the news over some economy sites. Here&amp;#039;s my question then: How can I correlate the news with the dollar variance over a set time? Can data science do that? How do I preprocess this, if at all? Do I need to use bag-of-words? At least I heard so... Please help and thank you for reading.</description>
<category>General</category>
<guid isPermaLink="true">https://ask.ghassem.com/1002/can-data-science-solve-this-problem</guid>
<pubDate>Sun, 24 Oct 2021 15:43:11 +0000</pubDate>
</item>
<item>
<title>How to remove unwanted Jupyter notebook kernels?</title>
<link>https://ask.ghassem.com/947/how-to-remove-unwanted-jupyter-notebook-kernels</link>
<description>Whener I run Jupyter notebook there are some kernels that do not exist on system and generate errors. How can I remove them?</description>
<category>General</category>
<guid isPermaLink="true">https://ask.ghassem.com/947/how-to-remove-unwanted-jupyter-notebook-kernels</guid>
<pubDate>Fri, 30 Oct 2020 17:15:17 +0000</pubDate>
</item>
<item>
<title>How to print confusion matrix if I am using stratifiedkfold method?</title>
<link>https://ask.ghassem.com/894/how-to-print-confusion-matrix-using-stratifiedkfold-method</link>
<description></description>
<category>Python</category>
<guid isPermaLink="true">https://ask.ghassem.com/894/how-to-print-confusion-matrix-using-stratifiedkfold-method</guid>
<pubDate>Thu, 06 Aug 2020 21:41:19 +0000</pubDate>
</item>
<item>
<title>I am facing the error after importing torch module in python. How can I solve it? The error link is given below</title>
<link>https://ask.ghassem.com/893/facing-error-after-importing-torch-module-python-solve-error</link>
<description>&lt;p&gt;&lt;img alt=&quot;&quot; src=&quot;https://ibb.co/MgXvrkL&quot;&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://ibb.co/MgXvrkL&quot;&gt;https://ibb.co/MgXvrkL&lt;/a&gt;&lt;/p&gt;</description>
<category>Python</category>
<guid isPermaLink="true">https://ask.ghassem.com/893/facing-error-after-importing-torch-module-python-solve-error</guid>
<pubDate>Fri, 31 Jul 2020 14:56:42 +0000</pubDate>
</item>
<item>
<title>What is difference between Support vector machine and Support Vector Classification?</title>
<link>https://ask.ghassem.com/863/difference-between-support-machine-support-classification</link>
<description></description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/863/difference-between-support-machine-support-classification</guid>
<pubDate>Wed, 13 May 2020 20:22:23 +0000</pubDate>
</item>
<item>
<title>How to share a Jupyter Notebook document on Google Colab?</title>
<link>https://ask.ghassem.com/836/how-to-share-a-jupyter-notebook-document-on-google-colab</link>
<description>How can I give access to others to view, comment or edit my Jupyter Notebook on Google Colab?</description>
<category>General</category>
<guid isPermaLink="true">https://ask.ghassem.com/836/how-to-share-a-jupyter-notebook-document-on-google-colab</guid>
<pubDate>Thu, 27 Feb 2020 16:17:13 +0000</pubDate>
</item>
<item>
<title>How to filter a dataframe?</title>
<link>https://ask.ghassem.com/775/how-to-filter-a-dataframe</link>
<description>&lt;p&gt;Consider the Pandas DataDrame&amp;nbsp;&lt;code&gt;df&lt;/code&gt;&amp;nbsp;below. Filter it appropriately so that it outputs the shown results.&lt;/p&gt;

&lt;pre class=&quot;prettyprint lang-python&quot; data-pbcklang=&quot;python&quot; data-pbcktabsize=&quot;4&quot;&gt;
     gh owner language      repo  stars
0  pandas-dev   python    pandas  17800
1   tidyverse        R     dplyr   2800
2   tidyverse        R   ggplot2   3500
3      has2k1   python  plotnine   1450&lt;/pre&gt;

&lt;h2&gt;Expected Output&lt;/h2&gt;

&lt;pre class=&quot;prettyprint lang-&quot; data-pbcklang=&quot;&quot; data-pbcktabsize=&quot;&quot;&gt;
     gh owner language    repo  stars
0  pandas-dev   python  pandas  17800&lt;/pre&gt;</description>
<category>Python Interview Questions</category>
<guid isPermaLink="true">https://ask.ghassem.com/775/how-to-filter-a-dataframe</guid>
<pubDate>Wed, 25 Dec 2019 05:56:14 +0000</pubDate>
</item>
<item>
<title>How does break, continue and pass work in Python?</title>
<link>https://ask.ghassem.com/711/how-does-break-continue-and-pass-work-in-python</link>
<description></description>
<category>Python Interview Questions</category>
<guid isPermaLink="true">https://ask.ghassem.com/711/how-does-break-continue-and-pass-work-in-python</guid>
<pubDate>Thu, 11 Jul 2019 17:07:58 +0000</pubDate>
</item>
<item>
<title>What are self and _init_ in Python classes?</title>
<link>https://ask.ghassem.com/709/what-are-self-and-init-in-python-classes</link>
<description></description>
<category>Python Interview Questions</category>
<guid isPermaLink="true">https://ask.ghassem.com/709/what-are-self-and-init-in-python-classes</guid>
<pubDate>Thu, 11 Jul 2019 17:00:39 +0000</pubDate>
</item>
<item>
<title>What are classes in Python?</title>
<link>https://ask.ghassem.com/707/what-are-classes-in-python</link>
<description></description>
<category>Python Interview Questions</category>
<guid isPermaLink="true">https://ask.ghassem.com/707/what-are-classes-in-python</guid>
<pubDate>Thu, 11 Jul 2019 16:40:21 +0000</pubDate>
</item>
<item>
<title>What are functions In Python?</title>
<link>https://ask.ghassem.com/705/what-are-functions-in-python</link>
<description></description>
<category>Python Interview Questions</category>
<guid isPermaLink="true">https://ask.ghassem.com/705/what-are-functions-in-python</guid>
<pubDate>Thu, 11 Jul 2019 16:24:29 +0000</pubDate>
</item>
<item>
<title>What is the difference between Python Arrays and Lists?</title>
<link>https://ask.ghassem.com/703/what-is-the-difference-between-python-arrays-and-lists</link>
<description></description>
<category>Python Interview Questions</category>
<guid isPermaLink="true">https://ask.ghassem.com/703/what-is-the-difference-between-python-arrays-and-lists</guid>
<pubDate>Thu, 11 Jul 2019 16:18:22 +0000</pubDate>
</item>
<item>
<title>Is indentation required in Python?  Is Python case-sensitive?</title>
<link>https://ask.ghassem.com/701/is-indentation-required-in-python-is-python-case-sensitive</link>
<description></description>
<category>Python Interview Questions</category>
<guid isPermaLink="true">https://ask.ghassem.com/701/is-indentation-required-in-python-is-python-case-sensitive</guid>
<pubDate>Thu, 11 Jul 2019 16:16:37 +0000</pubDate>
</item>
<item>
<title>What is type conversion in Python?</title>
<link>https://ask.ghassem.com/699/what-is-type-conversion-in-python</link>
<description></description>
<category>Python Interview Questions</category>
<guid isPermaLink="true">https://ask.ghassem.com/699/what-is-type-conversion-in-python</guid>
<pubDate>Tue, 09 Jul 2019 19:48:13 +0000</pubDate>
</item>
<item>
<title>What are the local variables and global variables in Python?</title>
<link>https://ask.ghassem.com/697/what-are-the-local-variables-and-global-variables-in-python</link>
<description></description>
<category>Python Interview Questions</category>
<guid isPermaLink="true">https://ask.ghassem.com/697/what-are-the-local-variables-and-global-variables-in-python</guid>
<pubDate>Tue, 09 Jul 2019 19:08:20 +0000</pubDate>
</item>
<item>
<title>What are python modules? Name some commonly used built-in modules in Python?</title>
<link>https://ask.ghassem.com/695/what-python-modules-name-some-commonly-built-modules-python</link>
<description></description>
<category>Python Interview Questions</category>
<guid isPermaLink="true">https://ask.ghassem.com/695/what-python-modules-name-some-commonly-built-modules-python</guid>
<pubDate>Tue, 09 Jul 2019 19:02:38 +0000</pubDate>
</item>
<item>
<title>What is PYTHONPATH in Python?</title>
<link>https://ask.ghassem.com/693/what-is-pythonpath-in-python</link>
<description></description>
<category>Python Interview Questions</category>
<guid isPermaLink="true">https://ask.ghassem.com/693/what-is-pythonpath-in-python</guid>
<pubDate>Tue, 09 Jul 2019 19:01:25 +0000</pubDate>
</item>
<item>
<title>What is a namespace in Python?</title>
<link>https://ask.ghassem.com/691/what-is-a-namespace-in-python</link>
<description></description>
<category>Python Interview Questions</category>
<guid isPermaLink="true">https://ask.ghassem.com/691/what-is-a-namespace-in-python</guid>
<pubDate>Tue, 09 Jul 2019 18:52:00 +0000</pubDate>
</item>
<item>
<title>How is memory management in Python?</title>
<link>https://ask.ghassem.com/689/how-is-memory-management-in-python</link>
<description></description>
<category>Python Interview Questions</category>
<guid isPermaLink="true">https://ask.ghassem.com/689/how-is-memory-management-in-python</guid>
<pubDate>Tue, 09 Jul 2019 18:41:01 +0000</pubDate>
</item>
<item>
<title>What is PEP8 in Python?</title>
<link>https://ask.ghassem.com/687/what-is-pep8-in-python</link>
<description></description>
<category>Python Interview Questions</category>
<guid isPermaLink="true">https://ask.ghassem.com/687/what-is-pep8-in-python</guid>
<pubDate>Tue, 09 Jul 2019 18:39:42 +0000</pubDate>
</item>
<item>
<title>How is Python an interpreted language?</title>
<link>https://ask.ghassem.com/685/how-is-python-an-interpreted-language</link>
<description></description>
<category>Python Interview Questions</category>
<guid isPermaLink="true">https://ask.ghassem.com/685/how-is-python-an-interpreted-language</guid>
<pubDate>Tue, 09 Jul 2019 18:37:52 +0000</pubDate>
</item>
<item>
<title>What type of language is python? Programming or scripting?</title>
<link>https://ask.ghassem.com/683/what-type-of-language-is-python-programming-or-scripting</link>
<description></description>
<category>Python Interview Questions</category>
<guid isPermaLink="true">https://ask.ghassem.com/683/what-type-of-language-is-python-programming-or-scripting</guid>
<pubDate>Tue, 09 Jul 2019 18:32:30 +0000</pubDate>
</item>
<item>
<title>What are the key features of Python?</title>
<link>https://ask.ghassem.com/681/what-are-the-key-features-of-python</link>
<description></description>
<category>Python Interview Questions</category>
<guid isPermaLink="true">https://ask.ghassem.com/681/what-are-the-key-features-of-python</guid>
<pubDate>Tue, 09 Jul 2019 18:24:25 +0000</pubDate>
</item>
<item>
<title>What is the difference between list and tuples in Python?</title>
<link>https://ask.ghassem.com/679/what-is-the-difference-between-list-and-tuples-in-python</link>
<description></description>
<category>Python Interview Questions</category>
<guid isPermaLink="true">https://ask.ghassem.com/679/what-is-the-difference-between-list-and-tuples-in-python</guid>
<pubDate>Tue, 09 Jul 2019 18:20:40 +0000</pubDate>
</item>
<item>
<title>What are the most important Python libraries for data science?</title>
<link>https://ask.ghassem.com/677/what-are-the-most-important-python-libraries-for-data-science</link>
<description></description>
<category>General</category>
<guid isPermaLink="true">https://ask.ghassem.com/677/what-are-the-most-important-python-libraries-for-data-science</guid>
<pubDate>Mon, 08 Jul 2019 04:42:28 +0000</pubDate>
</item>
<item>
<title>What are the available libraries for continuous time hidden markov models ?</title>
<link>https://ask.ghassem.com/640/what-available-libraries-continuous-hidden-markov-models</link>
<description></description>
<category>Data Science</category>
<guid isPermaLink="true">https://ask.ghassem.com/640/what-available-libraries-continuous-hidden-markov-models</guid>
<pubDate>Fri, 07 Jun 2019 13:27:05 +0000</pubDate>
</item>
<item>
<title>What are some best features of Python3 in comparison to Python2?</title>
<link>https://ask.ghassem.com/636/what-are-some-best-features-of-python3-in-comparison-python2</link>
<description>Python3 and Python2 seems so similar, and the only changes which are obvious are some changes in functions such as print that now needs parentheses. Are there other improvements?</description>
<category>Python</category>
<guid isPermaLink="true">https://ask.ghassem.com/636/what-are-some-best-features-of-python3-in-comparison-python2</guid>
<pubDate>Mon, 20 May 2019 16:11:31 +0000</pubDate>
</item>
<item>
<title>How to open Jupyter notebook files on Windows or Mac without web browser?</title>
<link>https://ask.ghassem.com/585/how-open-jupyter-notebook-files-windows-mac-without-browser</link>
<description></description>
<category>General</category>
<guid isPermaLink="true">https://ask.ghassem.com/585/how-open-jupyter-notebook-files-windows-mac-without-browser</guid>
<pubDate>Sat, 16 Mar 2019 23:36:01 +0000</pubDate>
</item>
<item>
<title>Who can write a recursive Python program for Fibonacci sequence 0,1,1,2,3,5,8,...?</title>
<link>https://ask.ghassem.com/583/who-can-write-recursive-python-program-fibonacci-sequence</link>
<description>Please also check if the fibo(7) = 8</description>
<category>Python</category>
<guid isPermaLink="true">https://ask.ghassem.com/583/who-can-write-recursive-python-program-fibonacci-sequence</guid>
<pubDate>Fri, 15 Mar 2019 20:33:17 +0000</pubDate>
</item>
<item>
<title>Passing variable length sentences to Tensorflow LSTM</title>
<link>https://ask.ghassem.com/561/passing-variable-length-sentences-to-tensorflow-lstm</link>
<description>&lt;p&gt;I have a tensorflow LSTM model for predicting the sentiment. I build the model with the maximum sequence length 150. (Maximum number of words) While making predictions, i have written the code as below:&lt;/p&gt;

&lt;pre class=&quot;prettyprint lang-python&quot; data-pbcklang=&quot;python&quot; data-pbcktabsize=&quot;4&quot;&gt;
batchSize = 32
maxSeqLength = 150

def getSentenceMatrix(sentence):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;arr = np.zeros([batchSize, maxSeqLength])
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sentenceMatrix = np.zeros([batchSize,maxSeqLength], dtype=&#039;int32&#039;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cleanedSentence = cleanSentences(sentence)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cleanedSentence = &#039; &#039;.join(cleanedSentence.split()[:150])
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;split = cleanedSentence.split()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for indexCounter,word in enumerate(split):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;try:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sentenceMatrix[0,indexCounter] = wordsList.index(word)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;except ValueError:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sentenceMatrix[0,indexCounter] = 399999 #Vector for unkown words
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return sentenceMatrix

input_text = &quot;example data&quot;
inputMatrix = getSentenceMatrix(input_text)&lt;/pre&gt;

&lt;p&gt;&lt;br&gt;
&lt;br&gt;
In the code i&#039;m truncating my input text to 150 words and ignoring remaining data.Due to this my predictions are wrong.&lt;/p&gt;

&lt;pre class=&quot;prettyprint lang-python&quot; data-pbcklang=&quot;python&quot; data-pbcktabsize=&quot;4&quot;&gt;
cleanedSentence = &#039; &#039;.join(cleanedSentence.split()[:150]) &lt;/pre&gt;

&lt;p&gt;&lt;br&gt;
I know that if we have lesser length than sequence length we can pad with zero&#039;s. What we need to do if we have more length. Can you suggest me the best way to do this. Thanks in advance.&lt;/p&gt;</description>
<category>General</category>
<guid isPermaLink="true">https://ask.ghassem.com/561/passing-variable-length-sentences-to-tensorflow-lstm</guid>
<pubDate>Mon, 11 Feb 2019 05:06:27 +0000</pubDate>
</item>
<item>
<title>How to find the strength of a P-value against a null hypothesis?</title>
<link>https://ask.ghassem.com/545/how-to-find-the-strength-of-a-p-value-against-null-hypothesis</link>
<description></description>
<category>Statistics</category>
<guid isPermaLink="true">https://ask.ghassem.com/545/how-to-find-the-strength-of-a-p-value-against-null-hypothesis</guid>
<pubDate>Fri, 07 Dec 2018 22:31:33 +0000</pubDate>
</item>
<item>
<title>I&#039;m wondering how I can copy files from my computer to the server on Digital Cloud?</title>
<link>https://ask.ghassem.com/541/wondering-how-copy-files-from-computer-server-digital-cloud</link>
<description>I&amp;#039;ve created a server on Digital Ocean, and employed uWSGI + NGINX to run a Flask application on the Ubuntu server. I need to copy some files from my computer to the server, yet typical methods such as using PuTTY tools (pscp) didn&amp;#039;t seem to work properly!&lt;br /&gt;
&lt;br /&gt;
Your advice is highly appreciated.</description>
<category>Web Development</category>
<guid isPermaLink="true">https://ask.ghassem.com/541/wondering-how-copy-files-from-computer-server-digital-cloud</guid>
<pubDate>Thu, 06 Dec 2018 18:20:56 +0000</pubDate>
</item>
<item>
<title>Merging data using dates</title>
<link>https://ask.ghassem.com/536/merging-data-using-dates</link>
<description>&lt;table border=&quot;0&quot; cellpadding=&quot;1&quot; style=&quot;width:400px&quot;&gt;
	&lt;tbody&gt;
		&lt;tr&gt;
			&lt;td&gt;Index&lt;/td&gt;
			&lt;td&gt;&amp;nbsp;&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;_d.index incident data&lt;/td&gt;
			&lt;td&gt;
			&lt;pre&gt;
DatetimeIndex([&#039;2011-01-01 00:03:43&#039;, &#039;2011-01-01 00:03:55&#039;,
               &#039;2011-01-01 00:05:03&#039;, &#039;2011-01-01 00:04:46&#039;,
               &#039;2011-01-01 00:06:07&#039;, &#039;2011-01-01 00:06:24&#039;,
               &#039;2011-01-01 00:06:48&#039;, &#039;2011-01-01 00:08:26&#039;,
               &#039;2011-01-01 00:08:56&#039;, &#039;2011-01-01 00:09:33&#039;,
               ...
               &#039;2016-12-31 23:34:26&#039;, &#039;2016-12-31 23:40:22&#039;,
               &#039;2016-12-31 23:47:01&#039;, &#039;2016-12-31 23:48:07&#039;,
               &#039;2016-12-31 23:52:56&#039;, &#039;2016-12-31 23:52:49&#039;,
               &#039;2016-12-31 23:55:44&#039;, &#039;2016-12-31 23:56:01&#039;,
               &#039;2016-12-31 23:59:18&#039;, &#039;2016-12-31 23:59:52&#039;],
              dtype=&#039;datetime64[ns]&#039;, name=&#039;incident_date_time&#039;, length=720370, freq=None)&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;_dw.index weather data&lt;/td&gt;
			&lt;td&gt;
			&lt;pre&gt;
DatetimeIndex([&#039;2011-01-01 00:00:00&#039;, &#039;2011-01-01 01:00:00&#039;,
               &#039;2011-01-01 02:00:00&#039;, &#039;2011-01-01 02:41:00&#039;,
               &#039;2011-01-01 03:00:00&#039;, &#039;2011-01-01 04:00:00&#039;,
               &#039;2011-01-01 07:00:00&#039;, &#039;2011-01-01 08:00:00&#039;,
               &#039;2011-01-01 09:00:00&#039;, &#039;2011-01-01 10:00:00&#039;,
               ...
               &#039;2016-12-31 17:00:00&#039;, &#039;2016-12-31 18:00:00&#039;,
               &#039;2016-12-31 19:00:00&#039;, &#039;2016-12-31 20:00:00&#039;,
               &#039;2016-12-31 21:00:00&#039;, &#039;2016-12-31 21:19:00&#039;,
               &#039;2016-12-31 22:00:00&#039;, &#039;2016-12-31 22:10:00&#039;,
               &#039;2016-12-31 22:50:00&#039;, &#039;2016-12-31 23:00:00&#039;],
              dtype=&#039;datetime64[ns]&#039;, name=&#039;date&#039;, length=62021, freq=None)&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
	&lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;For the TFS project, I would like to join the weather to the data by date and hour. for example the weather at 2011-01-01 01:00:00 to all the incidents for that hour 2011-01-01 01:00:00 and 2011-01-01 01:10:00 etc. One weather report to many incidents.&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description>
<category>Machine Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/536/merging-data-using-dates</guid>
<pubDate>Wed, 05 Dec 2018 12:39:41 +0000</pubDate>
</item>
<item>
<title>What will be probability for the data items within mean +- 1, +-2, +-3 standard deviation?</title>
<link>https://ask.ghassem.com/520/what-will-probability-data-items-within-standard-deviation</link>
<description></description>
<category>general</category>
<guid isPermaLink="true">https://ask.ghassem.com/520/what-will-probability-data-items-within-standard-deviation</guid>
<pubDate>Wed, 14 Nov 2018 15:10:15 +0000</pubDate>
</item>
<item>
<title>How much percentage of data items are consumed within mean +-1 , +-2, +-3 standard deviation?</title>
<link>https://ask.ghassem.com/518/much-percentage-items-consumed-within-standard-deviation</link>
<description></description>
<category>general</category>
<guid isPermaLink="true">https://ask.ghassem.com/518/much-percentage-items-consumed-within-standard-deviation</guid>
<pubDate>Wed, 14 Nov 2018 15:04:52 +0000</pubDate>
</item>
<item>
<title>Training neutral net with Tensor Flow</title>
<link>https://ask.ghassem.com/513/training-neutral-net-with-tensor-flow</link>
<description>Hello,&lt;br /&gt;
&lt;br /&gt;
I have a jpeg, where each image is around 1080 x 2048 in size and I have around 3000 of those images. I want to train a simple NN on this data. However, I am not sure how to feed the image data in to tensor flow. The examples online have a minst data which is easier since the image size is smaller.&lt;br /&gt;
&lt;br /&gt;
When i tried make an numpy array out of the images I have i get the memory exception.&lt;br /&gt;
&lt;br /&gt;
Any help would be appreciated !</description>
<category>Deep Learning</category>
<guid isPermaLink="true">https://ask.ghassem.com/513/training-neutral-net-with-tensor-flow</guid>
<pubDate>Mon, 12 Nov 2018 20:09:54 +0000</pubDate>
</item>
<item>
<title>What are Decorators?</title>
<link>https://ask.ghassem.com/472/what-are-decorators</link>
<description></description>
<category>Python</category>
<guid isPermaLink="true">https://ask.ghassem.com/472/what-are-decorators</guid>
<pubDate>Mon, 29 Oct 2018 22:59:50 +0000</pubDate>
</item>
<item>
<title>What is a Magic class methods ?</title>
<link>https://ask.ghassem.com/470/what-is-a-magic-class-methods</link>
<description></description>
<category>Python</category>
<guid isPermaLink="true">https://ask.ghassem.com/470/what-is-a-magic-class-methods</guid>
<pubDate>Mon, 29 Oct 2018 22:57:15 +0000</pubDate>
</item>
<item>
<title>If s=&#039;Sammy&#039; what is the output of s[2:]?</title>
<link>https://ask.ghassem.com/469/if-s-sammy-what-is-the-output-of-s-2</link>
<description></description>
<category>Python</category>
<guid isPermaLink="true">https://ask.ghassem.com/469/if-s-sammy-what-is-the-output-of-s-2</guid>
<pubDate>Mon, 29 Oct 2018 22:54:58 +0000</pubDate>
</item>
<item>
<title>How do I create comments in my code?</title>
<link>https://ask.ghassem.com/467/how-do-i-create-comments-in-my-code</link>
<description></description>
<category>Python</category>
<guid isPermaLink="true">https://ask.ghassem.com/467/how-do-i-create-comments-in-my-code</guid>
<pubDate>Mon, 29 Oct 2018 22:45:18 +0000</pubDate>
</item>
<item>
<title>How to discover outliers of a data frame?</title>
<link>https://ask.ghassem.com/455/how-to-discover-outliers-of-a-data-frame</link>
<description></description>
<category>Statistics</category>
<guid isPermaLink="true">https://ask.ghassem.com/455/how-to-discover-outliers-of-a-data-frame</guid>
<pubDate>Sun, 28 Oct 2018 11:20:51 +0000</pubDate>
</item>
<item>
<title>How to transform categorical variable into a matrix binary feature?</title>
<link>https://ask.ghassem.com/449/transform-categorical-variable-into-matrix-binary-feature</link>
<description>Which of the following feature transformations would be a good choice to transform a categorical variable into a matrix binary feature?&lt;br /&gt;
&lt;br /&gt;
A. One-hot-encoding&lt;br /&gt;
&lt;br /&gt;
B. Principal Component Analysis (PCA)&lt;br /&gt;
&lt;br /&gt;
C. Box-Cox&lt;br /&gt;
&lt;br /&gt;
D. Informative prior</description>
<category>Data Science Interview Questions</category>
<guid isPermaLink="true">https://ask.ghassem.com/449/transform-categorical-variable-into-matrix-binary-feature</guid>
<pubDate>Sat, 27 Oct 2018 17:23:08 +0000</pubDate>
</item>
<item>
<title>Hey, anyone knows how to save workspace in jupyter python? I would like to save the variables and functions, etc.</title>
<link>https://ask.ghassem.com/441/anyone-knows-workspace-jupyter-python-variables-functions</link>
<description></description>
<category>Python</category>
<guid isPermaLink="true">https://ask.ghassem.com/441/anyone-knows-workspace-jupyter-python-variables-functions</guid>
<pubDate>Wed, 24 Oct 2018 13:53:22 +0000</pubDate>
</item>
<item>
<title>ploting the xticks to be datatime</title>
<link>https://ask.ghassem.com/432/ploting-the-xticks-to-be-datatime</link>
<description>&lt;p&gt;I have a dataframe&amp;nbsp;like below&lt;/p&gt;

&lt;pre class=&quot;prettyprint lang-python&quot; data-pbcklang=&quot;python&quot; data-pbcktabsize=&quot;4&quot;&gt;
                    MT_001	    MT_002	    hour
2012-01-01 00:15:00	3.807107	22.759602	00:15:00
2012-01-01 00:30:00	5.076142	22.759602	00:30:00
2012-01-01 00:45:00	3.807107	22.759602	00:45:00
2012-01-01 01:00:00	3.807107	22.759602	01:00:00
2012-01-01 01:15:00	5.076142	22.048364	01:15:00&lt;/pre&gt;

&lt;p&gt;I can easily plot it using&lt;/p&gt;

&lt;pre class=&quot;prettyprint lang-python&quot; data-pbcklang=&quot;python&quot; data-pbcktabsize=&quot;4&quot;&gt;
data.plot()
plt.show()&lt;/pre&gt;

&lt;p&gt;However, this doesn&#039;t show the xlabel. What if i want to see the graph where the xlabel&amp;nbsp;shows the ticks&amp;nbsp;with 4 hours apart?&lt;/p&gt;</description>
<category>Python</category>
<guid isPermaLink="true">https://ask.ghassem.com/432/ploting-the-xticks-to-be-datatime</guid>
<pubDate>Sat, 20 Oct 2018 00:47:40 +0000</pubDate>
</item>
<item>
<title>What are basic steps for treating missing values?</title>
<link>https://ask.ghassem.com/430/what-are-basic-steps-for-treating-missing-values</link>
<description></description>
<category>Exploratory Data Analysis</category>
<guid isPermaLink="true">https://ask.ghassem.com/430/what-are-basic-steps-for-treating-missing-values</guid>
<pubDate>Fri, 19 Oct 2018 04:08:48 +0000</pubDate>
</item>
<item>
<title>What are the general steps in data cleaning?</title>
<link>https://ask.ghassem.com/427/what-are-the-general-steps-in-data-cleaning</link>
<description></description>
<category>General</category>
<guid isPermaLink="true">https://ask.ghassem.com/427/what-are-the-general-steps-in-data-cleaning</guid>
<pubDate>Fri, 19 Oct 2018 03:54:38 +0000</pubDate>
</item>
<item>
<title>How can you tell a Python library is a good one and useful?</title>
<link>https://ask.ghassem.com/425/how-can-you-tell-a-python-library-is-a-good-one-and-useful</link>
<description>If a big company such as Google behind it, with high probability it is a great library such as TensorFlow. But in general how can I found out?</description>
<category>Python</category>
<guid isPermaLink="true">https://ask.ghassem.com/425/how-can-you-tell-a-python-library-is-a-good-one-and-useful</guid>
<pubDate>Fri, 19 Oct 2018 03:46:23 +0000</pubDate>
</item>
</channel>
</rss>