Python+for+Finance+ +FAQ
Python+for+Finance+ +FAQ
FAQ
TABLE OF CONTENTS
PREFACE 3
How can I open the exercise files? And the *.ipynb files in general? 6
I have downloaded and installed Anaconda but I can’t find and start Jupyter 10
Preface
Here we will describe the process you need to go through whenever you encounter an error in programming.
Please read the following two pages carefully, as they will surely save you a lot of time in the long run!
Even the best programmers out there find it nearly impossible to successfully create the complex code
delivering the desired output the first time they write it. So, we can say coding is all about trying, stumbling
upon an error, reading the obtained error message, finding a solution, and then applying it. Over and over
again. In fact, this process is repeated infinitely.
Therefore, as a programmer, you need to develop the skill to quickly and efficiently identify and solve
problems that occur while you are coding.
With this question in mind, we will take you through the steps you should follow each time you encounter
an error:
2) If you encounter an error while you are replicating code you’ve seen in a lecture, please re-watch
that video or at least the parts about the query you are trying to execute. Remember that every
symbol and letter could make a difference! So don’t overlook the details – they might be the cause
of this error!
3) If the error occurs while you are trying to solve an exercise, please carefully check the notebook files
containing the corresponding solution.
4) In some situations, the 3 steps described above may not help. Or… you may still have a question,
even though you’ve managed to solve the error. In that case, please search among the existing
threads in the Q&A section. If you can’t find the answer to your question, you can post a new one
there.
1) While coding in Python, the order in which you execute the code cells matters. So, please double-
check to make sure you have executed all cells in the order shown in the lectures or the notebook
files.
2) Keep this FAQ sheet open, as it may contain the answer you are looking for. Use Ctrl + F to find a
keyword related to the problem you are trying to solve quickly.
Apart from questions related to coding in Python, you may wonder how to load the notebooks located in the
resources sections of the lectures, or how to obtain a certificate at the end of the course. We will deal with
such questions in the next section.
Use the FAQ sheet, the Q&A, and good luck while taking the course!
How can I open the exercise files and the *.ipynb files in general?
https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/6780016#questions/7247648
The notebook files (*.ipynb), located in the resources sections of the course lectures, cannot be opened by
double-clicking on them. You need to start Jupyter and load the notebook files as shown in Section 2, Lecture
7 Jupyter’s Interface – the Dashboard. Please refer to this video for a detailed explanation on how this is done
step-by-step.
Then, you can apply this technique to any of the notebook files attached to the lectures.
https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/6780282#questions/7252396
Sometimes students tell us that they have completed the course but they continue to see their progress as
less than 100%.
If you are experiencing the same problem, please check if there is any video that you have missed watching,
or have not finished for some reason. In both cases, Udemy may have not recorded the time you've spent on
these lectures.
If the issue persists, please contact Udemy Support, so that your 100% would be displayed and you could
obtain your certificate!
https://support.udemy.com/hc/en-us
https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/10526772#questions/7326932
Regarding the certification, please go to the course dashboard. On the right side of your progress, you will
see a trophy that you can click on. Then, follow the instructions on how to obtain your certificate!
If this is creating issues in your case, please refer to the following article or Udemy Support for more
information. Thank you!
https://support.udemy.com/hc/en-us/articles/229603868-Certificate-of-Completion
https://support.udemy.com/hc/en-us
I have downloaded and installed Anaconda but I can’t find and start Jupyter
https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/6780114#questions/4579968
https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/6780114#questions/5955972
https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/6780014
Windows users:
1) Run Jupyter Notebook from the shortcut found in the Start menu (this is the option shown in the
video).
2) Open Anaconda Prompt from the start menu and execute jupyter notebook
3) Open the Anaconda Navigator from the start menu and press the Launch button under the Jupyter
icon
If 1) does not work, Anaconda Prompt will usually tell you what the error is, so you can look for a specific
solution.
Please reinstall Anaconda in case none of these options works.
Mac users:
1) Open Terminal
https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/6779998#questions/5189930
https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/6780346
Unfortunately, this problem has to do with the different ways in which 32- and 64-bit systems work.
You may obtain an erroneous output (e.g. 26.046000000000003%) if the result of the round() function has
been multiplied by a hundred:
round(log_return_a, 5) * 100 .
On the contrary, such an erroneous output is not visualized if the round() function has been executed solely,
like this:
round(log_return_a, 5)
If you are interested and ready for a serious technical challenge, you can read more on this subject here.
https://github.com/bbcmicrobit/micropython/issues/367
https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/6780090
https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/6780092
https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/6780110
Assume you have a list x containing the following four numbers: 10, 20, 30, and 40.
print x,
https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/9521758#questions/7259420
https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/10774380
https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/6780108
First, please allow us to refer to Section 2, Lecture 9: Python 2 vs Python 3: What’s the Difference?, as well as
to the resources section of the same lecture. There, we provide explanations on the differences between the
two Python versions you need to know about while taking our course.
If you would like to obtain a list in Python 3 after using the range() function, please take advantage of the
following model:
list(range(10))
Different rules apply for Python 2. In Python 2, the range() will deliver as an output a list of values directly.
https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/6780344#questions/6708425
https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/6780122
An example of a convention is calling the web data web or wb . In our course, we obviously stick to the
second one.
But in terms of Python code, what does wb refer to? It refers to the data part of the pandas-datareader
package, right? That's why we begin our code with
from pandas_datareader import data as wb .
Having executed this line of code in your session (“session” meaning the period in which you will keep your
notebook and Jupyter open), Python will know that wb refers to the data part of the pandas-datareader
package. This is nothing but a large chunk of code where certain functions and methods have been specified.
Therefore, wb.DataReader() is simply an indication where Python should search for a method called
.DataReader() .
Other conventions are plt for pyplot matplotlib code, np for numpy, and pd for pandas. It is a sign of good
practice to stick to conventions such as np , plt , wb . That's why we use them in the course and advise you
to use them, too.
Note: Methods, on the other hand, have their fixed names, and you cannot really use an alias for them. You'd have to
create a new function or method, based on the initial method, and give it a name you like. However, this is not something
people normally do. Therefore, it is better to try to remember the method or function name you need.
https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/6780114#questions/4826264
https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/6780124
Apart from what you see in the lectures and exercises in Section 10, we are currently advised by Quandl to
always start our code with
quandl.ApiConfig.api_key = "YOUR_KEY_HERE" .
Furthermore, you have a limit of requests you can make with your key per day - currently, this limit is 50.
Keep this information in mind while working with data from Quandl.
https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/6780356#questions/6549270
Minute 3:45,
https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/6780124
Windows users:
Step #1) Execute pip install pandas-datareader in the Anaconda prompt (be aware that pandas-
datareader is spelled with a hyphen).
Step #2) Then, import it in a Jupyter document (i.e. an *.ipynb file) by executing from pandas_datareader
import data as wb (be aware that this time the two words are separated by an
underscore pandas_datareader ).
Mac users:
Apply the same instructions as Windows users. However, remember you should use Terminal instead of
Anaconda Prompt for Step #1. Step #2 is the same.
Occasionally, students who use Mac encounter an issue at Step #1 because they have not installed pip
beforehand. To see how to do that, please check the question about installing pip on Mac.
https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/6780114#questions/5463988
If you need admin privileges, please execute the following command instead:
sudo easy_install pip .
Then, you can proceed with pip-installing packages in Terminal in the universal way.
https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/6780114#questions/5888134
https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/6780284
For those of you who feel comfortable in using more advanced bits of code, here’s another way of dealing
with this problem.
To retrieve the path to the directory where the notebook file you’ve been working on has been stored and
where new files would be automatically saved, you need to execute the following lines of code.
import os, inspect
fx = inspect.getframeinfo(inspect.currentframe())[0]
else:
fx = __file__
os_dir = os.path.dirname(os.path.abspath(fx))
print(os_dir)
Having assigned the correct value to os_dir, all references to files could be represented as
mydata_01.to_csv(os.path.join(os_dir,"example_01.csv")) .
https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/6780114#questions/3948410
https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/6780344#overview
Not seeing the dates on a graph is something that is expected to happen while using the newest versions of
matplotlib. Below you can find a description of the code that will allow the dates to be displayed along the
horizontal line.
First, make sure you have imported ‘pandas’ and ‘matplotlib.pyplot’ earlier in your code.
import pandas as pd
Then, while creating a DataFrame (for simplicity – df ), regardless of whether you insert its content from an
online API or a *.csv file, make sure there is an index column called ‘date’.
Here’s the code if you choose to import the data from a *.csv file.
…
df = pd.DataFrame(pd.read_csv('sample.csv', index_col='date'))
At this stage, you need to convert the date column values into "datetime" format. After you have done that,
matplotlib is supposed to plot the x-axis correctly.
pd.to_datetime(df.date)
df.plot()
plt.show()