0% found this document useful (0 votes)
62 views

Python+for+Finance+ +FAQ

This document is a frequently asked questions (FAQ) sheet for a course on Python for finance. It addresses common questions about using the programming environment Jupyter Notebook, installing necessary packages, and working with financial data in Python. The FAQ is organized into sections on Udemy course-related questions, content questions, and provides steps to troubleshoot errors encountered while coding. It recommends carefully reading error messages, rewatching relevant lectures, checking solution notebooks, and searching existing questions before posting new ones for help.

Uploaded by

Viral Lodhia
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views

Python+for+Finance+ +FAQ

This document is a frequently asked questions (FAQ) sheet for a course on Python for finance. It addresses common questions about using the programming environment Jupyter Notebook, installing necessary packages, and working with financial data in Python. The FAQ is organized into sections on Udemy course-related questions, content questions, and provides steps to troubleshoot errors encountered while coding. It recommends carefully reading error messages, rewatching relevant lectures, checking solution notebooks, and searching existing questions before posting new ones for help.

Uploaded by

Viral Lodhia
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Python for Finance:

Investment Fundamentals and Data Analytics

FAQ
TABLE OF CONTENTS

PREFACE 3

QUESTIONS RELATED TO UDEMY AND THE SMOOTH TAKING OF THE COURSE 5

How can I open the exercise files? And the *.ipynb files in general? 6

Course completion not correctly displayed 7

How can I get my certificate for completing the course? 8

QUESTIONS RELATED TO THE CONTENT OF THE COURSE 9

I have downloaded and installed Anaconda but I can’t find and start Jupyter 10

round() does not work properly when applied to % return 11

Displaying elements from a list on the same row in Python 3 12

Using the range() function in Python 3 13

Using conventions in Python 14

Limits on using Quandl 15

Using and installing the pandas-datareader package 16

Installing Pip on Mac 17

Problems related to importing or exporting *.csv files 18

Matplotlib graphs are not showing dates on the horizontal axis 19


Back to the Table of Contents

Preface

IMPORTANT – PLEASE DON’T SKIP THIS PART!

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!

A general note on problem-solving

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.

What should I do when I encounter a coding error?

With this question in mind, we will take you through the steps you should follow each time you encounter
an error:

1) Read the error message carefully.


Every time you make a mistake, you will obtain an error message. Sometimes, this message will be
quite specific; you will be able to immediately spot the mistake and correct it. Other times, though, it
will sound more general. Then, it will be your job to find where the error stems from.

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.

How can I speed up the process of solving the encountered problems?

Python for Finance: Investment Fundamentals and Data Analytics - FAQ


Back to the Table of Contents

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.

Questions related to Udemy and the smooth taking of the course

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!

Python for Finance: Investment Fundamentals and Data Analytics - FAQ


Back to the Table of Contents

Questions related to Udemy and the smooth


taking of the course

Python for Finance: Investment Fundamentals and Data Analytics - FAQ


Back to the Table of Contents

How can I open the exercise files and the *.ipynb files in general?

Keywords: open, *.ipynb, exercise file, lecture file, solution file

Lecture for reference:

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.

Python for Finance: Investment Fundamentals and Data Analytics - FAQ


Back to the Table of Contents

Course completion not correctly displayed

Keywords: course completion, 100%

Q&A thread for reference:

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

Python for Finance: Investment Fundamentals and Data Analytics - FAQ


Back to the Table of Contents

How can I get my certificate for completing the course?

Keywords: complete, certificate, Udemy

Lecture for reference:

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

Python for Finance: Investment Fundamentals and Data Analytics - FAQ


Back to the Table of Contents

Questions related to the content of the


course

Python for Finance: Investment Fundamentals and Data Analytics - FAQ


Back to the Table of Contents

I have downloaded and installed Anaconda but I can’t find and start Jupyter

Keywords: install, Anaconda, launch, start, Jupyter

Q&A thread for reference:

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

Lecture for reference:

https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/6780014

Windows users:

There are three ways to start Jupyter.

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

2) Enter the startup folder by executing cd/folder_name

3) Execute jupyter notebook

Python for Finance: Investment Fundamentals and Data Analytics - FAQ


Back to the Table of Contents

round() does not work properly when applied to % return

Keywords: round(), return, %, percentage

Q&A thread for reference:

https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/6779998#questions/5189930

Lecture for reference:

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

Python for Finance: Investment Fundamentals and Data Analytics - FAQ


Back to the Table of Contents

Displaying elements from a list on the same row in Python 3

Keywords: Python 3, Python 2, list, elements, print x, , print (x, end = “ “)

Lecture for reference:

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

Please note the following difference between using Python 2 and 3.

Assume you have a list x containing the following four numbers: 10, 20, 30, and 40.

x = [10, 20, 30, 40]

To print all of the 4 elements on a line

in Python 2 you have to use the following syntax:

print x,

To obtain the same output in Python 3, you need to execute

print (x, end = “ “) .

Python for Finance: Investment Fundamentals and Data Analytics - FAQ


Back to the Table of Contents

Using the range() function in Python 3

Keywords: Python 3, range()

Q&A thread for reference:

https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/9521758#questions/7259420

Lecture for reference:

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.

Here’s a refresher, related to the use of the range() function in Python 3.

In Python 3, the range(1,10) command would result as an output of range(1,10) exactly.

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.

Python for Finance: Investment Fundamentals and Data Analytics - FAQ


Back to the Table of Contents

Using conventions in Python

Keywords: matplotlib, .plot, plt.show(), wb, pandas-datareader, pd, pandas, numpy, np

Q&A thread for reference:

https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/6780344#questions/6708425

Lecture for reference:

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.

Python for Finance: Investment Fundamentals and Data Analytics - FAQ


Back to the Table of Contents

Limits on using Quandl

Keywords: Quandl, API, API Key, daily limit

Q&A thread for reference:

https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/6780114#questions/4826264

Lecture for reference:

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.

Python for Finance: Investment Fundamentals and Data Analytics - FAQ


Back to the Table of Contents

Using and installing the pandas-datareader package

Keywords: install module, install package, pandas-datareader, import pandas_datareader

Q&A thread for reference:

https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/6780356#questions/6549270

Lecture for reference:

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.

Python for Finance: Investment Fundamentals and Data Analytics - FAQ


Back to the Table of Contents

Installing Pip on Mac

Keywords: Mac, install, pip

Q&A thread for reference:

https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/6780114#questions/5463988

Execute in Terminal the following command:


easy_install pip .

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.

Python for Finance: Investment Fundamentals and Data Analytics - FAQ


Back to the Table of Contents

Problems related to importing or exporting *.csv files

Keywords: import *.csv, export *.csv

Q&A thread for reference:

https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/6780114#questions/5888134

Lecture for reference:

https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/6780284

Users of any operating system:

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

if '__file__' not in locals():

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")) .

Python for Finance: Investment Fundamentals and Data Analytics - FAQ


Back to the Table of Contents

Matplotlib graphs are not showing dates on the horizontal axis

Keywords: matplotlib, x axis, horizontal axis, dates not shown

Q&A thread for reference:

https://www.udemy.com/python-for-finance-investment-fundamentals-data-
analytics/learn/lecture/6780114#questions/3948410

Lecture for reference:

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

import matplotlib.pyplot as plt

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()

Python for Finance: Investment Fundamentals and Data Analytics - FAQ

You might also like