Posted on Leave a comment

Pandas NaN — Working With Missing Data

Pandas is Excel on steroids—the powerful Python library allows you to analyze structured and tabular data with surprising efficiency and ease. Pandas is one of the reasons why master coders reach 100x the efficiency of average coders. In today’s article, you’ll learn how to work with missing data—in particular, how to handle NaN values in Pandas DataFrames.

You’ll learn about all the different reasons why NaNs appear in your DataFrames—and how to handle them. Let’s get started!

Checking Series for NaN Values

Problem: How to check a series for NaN values?

Have a look at the following code:

import pandas as pd
import numpy as np data = pd.Series([0, np.NaN, 2])
result = data.hasnans print(result)
# True

Series can contain NaN-values—an abbreviation for Not-A-Number—that describe undefined values.

To check if a Series contains one or more NaN value, use the attribute hasnans. The attribute returns True if there is at least one NaN value and False otherwise.

There’s a NaN value in the Series, so the output is True.

Filtering Series Generates NaN

Problem: When filtering a Series with where() and no element passes the filtering condition, what’s the result?

import pandas as pd xs = pd.Series([5, 1, 4, 2, 3])
xs.where(xs > 2, inplace=True)
result = xs.hasnans print(result)
# True

The method where() filters a Series by a condition. Only the elements that satisfy the condition remain in the resulting Series. And what happens if a value doesn’t satisfy the condition? Per default, all rows not satisfying the condition are filled with NaN-values.

This is why our Series contains NaN-values after filtering it with the method where().

Working with Multiple Series of Different Lengths

Problem: If you element-wise add two Series objects with a different number of elements—what happens with the remaining elements?

import pandas as pd s = pd.Series(range(0, 10))
t = pd.Series(range(0, 20))
result = (s + t)[1] print(result)
# 2

To add two Series element-wise, use the default addition operator +. The Series do not need to have the same size because once the first Series ends, the subsequent element-wise results are NaN values.

At index 1 in the resulting Series, you get the result of 1 + 1 = 2.

Create a DataFrame From a List of Dictionaries with Unequal Keys

Problem: How to create a DataFrame from a list of dictionaries if the dictionaries have unequal keys? A DataFrame expects the same columns to be available for each row!

import pandas as pd data = [{'Car':'Mercedes', 'Driver':'Hamilton, Lewis'}, {'Car':'Ferrari', 'Driver':'Schumacher, Michael'}, {'Car':'Lamborghini'}] df = pd.DataFrame(data, index=['Rank 2', 'Rank 1', 'Rank 3'])
df.sort_index(inplace=True)
result = df['Car'].iloc[0] print(result)
# Ferrari

You can create a DataFrame from a list of dictionaries. The dictionaries’ keys define the column labels, and the values define the columns’ entries. Not all dictionaries must contain the same keys. If a dictionary doesn’t contain a particular key, this will be interpreted as a NaN-value.

This code snippet uses string labels as index values to sort the DataFrame. After sorting the DataFrame, the row with index label Rank 1 is at location 0 in the DataFrame and the value in the column Car is Ferrari.

Sorting a DataFrame by Column with NaN Values

Problem: What happens if you sort a DataFrame by column if the column contains a NaN value?

import pandas as pd df = pd.read_csv("Cars.csv") # Dataframe "df"
# ----------
# make fuel aspiration body-style price engine-size
# 0 audi gas turbo sedan 30000 2.0
# 1 dodge gas std sedan 17000 1.8
# 2 mazda diesel std sedan 17000 NaN
# 3 porsche gas turbo convertible 120000 6.0
# 4 volvo diesel std sedan 25000 2.0
# ---------- selection = df.sort_values(by="engine-size")
result = selection.index.to_list()[0]
print(result)
# 1

In this code snippet, you sort the rows of the DataFrame by the values of the column engine-size.

The main point is that NaN values are always moved to the end in Pandas sorting. Thus, the first value is 1.8, which belongs to the row with index value 1.

Count Non-NaN Values

Problem: How to count the number of elements in a dataframe column that are not Nan?

import pandas as pd df = pd.read_csv("Cars.csv") # Dataframe "df"
# ----------
# make fuel aspiration body-style price engine-size
# 0 audi gas turbo sedan 30000 2.0
# 1 dodge gas std sedan 17000 1.8
# 2 mazda diesel std sedan 17000 NaN
# 3 porsche gas turbo convertible 120000 6.0
# 4 volvo diesel std sedan 25000 2.0
# ---------- df.count()[5]
print(result)
# 4

The method count() returns the number of non-NaN values for each column. The DataFrame df has five rows. The fifth column
contains one NaN value. Therefore, the count of the fifth column is 4.

Drop NaN-Values

Problem: How to drop all rows that contain a NaN value in any of its columns—and how to restrict this to certain columns?

import pandas as pd df = pd.read_csv("Cars.csv") # Dataframe "df"
# ----------
# make fuel aspiration body-style price engine-size
# 0 audi gas turbo sedan 30000 2.0
# 1 dodge gas std sedan 17000 1.8
# 2 mazda diesel std sedan 17000 NaN
# 3 porsche gas turbo convertible 120000 6.0
# 4 volvo diesel std sedan 25000 2.0
# ---------- selection1 = df.dropna(subset=["price"])
selection2 = df.dropna()
print(len(selection1), len(selection2))
# 5 4

The DataFrame’s dropna() method drops all rows that contain a NaN value in any of its columns. But how to restrict the columns to be scanned for NaN values?

By passing a list of column labels to the optional parameter subset, you can define which columns you want to consider.

The call of dropna() without restriction, drops line 2 because of the NaN value in the column engine-size. When you restrict the columns only to price, no rows will be dropped, because no NaN value is present.

Drop Nan and Reset Index

Problem: What happens to indices after dropping certain rows?

import pandas as pd df = pd.read_csv("Cars.csv") # Dataframe "df"
# ----------
# make fuel aspiration body-style price engine-size
# 0 audi gas turbo sedan 30000 2.0
# 1 dodge gas std sedan 17000 1.8
# 2 mazda diesel std sedan 17000 NaN
# 3 porsche gas turbo convertible 120000 6.0
# 4 volvo diesel std sedan 25000 2.0
# ---------- df.drop([0, 1, 2], inplace=True)
df.reset_index(inplace=True)
result = df.index.to_list()
print(result)
# [0, 1]

The method drop() on a DataFrame deletes rows or columns by index. You can either pass a single value or a list of values.

By default the inplace parameter is set to False, so that modifications won’t affect the initial DataFrame object. Instead, the method returns a modified copy of the DataFrame. In the puzzle, you set inplace to True, so the deletions are performed directly on the DataFrame.

After deleting the first three rows, the first two index labels are 3 and 4. You can reset the default indexing by calling the method reset_index() on the DataFrame, so that the index starts at 0 again. As there are only two rows left in the DataFrame, the result is [0, 1].

Concatenation of Dissimilar DataFrames Filled With NaN

Problem: How to concatenate two DataFrames if they have different columns?

import pandas as pd df = pd.read_csv("Cars.csv")
df2 = pd.read_csv("Cars2.csv") # Dataframe "df"
# ----------
# make fuel aspiration body-style price engine-size
# 0 audi gas turbo sedan 30000 2.0
# 1 dodge gas std sedan 17000 1.8
# 2 mazda diesel std sedan 17000 NaN
# 3 porsche gas turbo convertible 120000 6.0
# 4 volvo diesel std sedan 25000 2.0
# ---------- # Additional Dataframe "df2"
# ----------
# make origin
# 0 skoda Czechia
# 1 toyota Japan
# 2 ford USA
# ---------- try: result = pd.concat([df, df2], axis=0, ignore_index=True) print("Y")
except Exception: print ("N") # Y

Even if DataFrames have different columns, you can concatenate them.

If DataFrame 1 has columns A and B and DataFrame 2 has columns C and D, the result of concatenating DataFrames 1 and 2 is a DataFrame with columns A, B, C, and D. Missing values in the rows are filled with NaN.

Outer Merge

Problem: When merging (=joining) two DataFrames—what happens if there are missing values?

import pandas as pd df = pd.read_csv("Cars.csv")
df2 = pd.read_csv("Cars2.csv") # Dataframe "df"
# ----------
# make fuel aspiration body-style price engine-size
# 0 audi gas turbo sedan 30000 2.0
# 1 dodge gas std sedan 17000 1.8
# 2 mazda diesel std sedan 17000 NaN
# 3 porsche gas turbo convertible 120000 6.0
# 4 volvo diesel std sedan 25000 2.0
# ---------- # Additional dataframe "df2"
# ----------
# make origin
# 0 skoda Czechia
# 1 mazda Japan
# 2 ford USA
# ---------- result = pd.merge(df, df2, how="outer", left_on="make", right_on="make")
print(len(result["fuel"]))
print(result["fuel"].count())
# 7
# 5

With Panda’s function merge() and the parameter how set to outer, you can perform an outer join.

The resulting DataFrame of an outer join contains all values from both input DataFrames; missing values are filled with NaN.

In addition, this puzzle shows how NaN values are counted by the len() function whereas the method count() does not include NaN values.

Replacing NaN

Problem: How to Replace all NaN values in a DataFrame with a given value?

import pandas as pd df = pd.read_csv("Cars.csv") # Dataframe "df"
# ----------
# make fuel aspiration body-style price engine-size
# 0 audi gas turbo sedan 30000 2.0
# 1 dodge gas std sedan 17000 1.8
# 2 mazda diesel std sedan 17000 NaN
# 3 porsche gas turbo convertible 120000 6.0
# 4 volvo diesel std sedan 25000 2.0
# ---------- df.fillna(2.0, inplace=True)
result = df["engine-size"].sum()
print(result)
# 13.8

The method fillna() replaces NaN values with a new value. Thus, the sum of all values in the column engine-size is 13.8.

Length vs. Count Difference — It’s NaN!

Problem: What’s the difference between the len() and the count() functions?

import pandas as pd df = pd.read_csv("Cars.csv")
df2 = pd.read_csv("Cars2.csv") # Dataframe "df"
# ----------
# make fuel aspiration body-style price engine-size
# 0 audi gas turbo sedan 30000 2.0
# 1 dodge gas std sedan 17000 1.8
# 2 mazda diesel std sedan 17000 NaN
# 3 porsche gas turbo convertible 120000 6.0
# 4 volvo diesel std sedan 25000 2.0
# ---------- # Additional dataframe "df2"
# ----------
# make origin
# 0 skoda Czechia
# 1 mazda Japan
# 2 ford USA
# ---------- result = pd.merge(df2, df, how="left", left_on="make", right_on="make")
print(len(result["fuel"]))
print(result["fuel"].count())
# 3
# 1

In a left join, the left DataFrame is the master, and all its values are included in the resulting DataFrame.

Therefore, the result DataFrame contains three rows, yet, since skoda and ford don’t appear in DataFrame df, only one the row for mazda contains value.

Again, we see the difference between using the function len() which also includes NaN values and the method count() which does not count NaN values.

Equals() vs. == When Comparing NaN

Problem:

import pandas as pd df = pd.read_csv("Cars.csv") # Dataframe "df"
# ----------
# make fuel aspiration body-style price engine-size
# 0 audi gas turbo sedan 30000 2.0
# 1 dodge gas std sedan 17000 1.8
# 2 mazda diesel std sedan 17000 NaN
# 3 porsche gas turbo convertible 120000 6.0
# 4 volvo diesel std sedan 25000 2.0
# ---------- df["engine-size_copy"] = df["engine-size"]
check1 = (df["engine-size_copy"] == df["engine-size"]).all()
check2 = df["engine-size_copy"].equals(df["engine-size"])
print(check1 == check2)
# False

This code snippet shows how to compare columns or entire DataFrames regarding the shape and the elements.

The comparison using the operator == returns False for our DataFrame because the comparing NaN-values with == always yields False.

On the other hand, df.equals() allows comparing two Series or DataFrames. In this case, NaN-values in the same location are considered to be equal.

The column headers do not need to have the same type, but the elements within the columns must be of the same dtype.

Since the result of check1 is False and the result of check2 yields True, the final output is False.

Where to Go From Here?

Enough theory, let’s get some practice!

To become successful in coding, you need to get out there and solve real problems for real people. That’s how you can become a six-figure earner easily. And that’s how you polish the skills you really need in practice. After all, what’s the use of learning theory that nobody ever needs?

Practice projects is how you sharpen your saw in coding!

Do you want to become a code master by focusing on practical code projects that actually earn you money and solve problems for people?

Then become a Python freelance developer! It’s the best way of approaching the task of improving your Python skills—even if you are a complete beginner.

Join my free webinar “How to Build Your High-Income Skill Python” and watch how I grew my coding business online and how you can, too—from the comfort of your own home.

Join the free webinar now!

The post Pandas NaN — Working With Missing Data first appeared on Finxter.

Posted on Leave a comment

How to Be a Freelance Developer in Germany

Being a Python freelancer is a new way of living in the 21st century. It’s a path of personal growth, learning new skills, and earning money in the process. But in today’s digital economy, becoming a Python freelancer is – above everything else – a lifestyle choice. It can give you fulfillment, flexibility, and endless growth opportunities. Additionally, it offers you a unique way of connecting with other people, learning about their exciting projects, and finding friends and acquaintances on the way.

Disclaimer: Please don’t take this as legal advice but as tips & tricks from someone who’s been there and done that.

Freelance Developer Germany Pros and Cons

So what are the advantages of being a freelance coder? Let’s dive right into them.

Advantages of Being a Freelance Programmer in Germany

  • Flexibility: One big advantage of being a Python freelancer is that you are flexible in time and space. I live in a large German city (Stuttgart) where rent prices are increasing. However, since I am working full-time in the Python industry, being self-employed, and 100% digital, I have the freedom to move to the countryside. Outside large cities, housing is exceptionally cheap and living expenses are truly affordable. I am earning good money matched only by a few employees in my home town — while I am not forced to compete for housing to live close to my employers.  A few cities demand very high prices in Germany while others allow you to get affordable and beautiful houses in the countryside. A clear advantage for freelance developers!
  • Independence: Do you hate working for your boss? Does your boss still value old-school values such as working 9-to-5? In Germany, a lot of bosses are that way. Being a freelancer injects a dose of true independence into your life. While you are not totally free (after all, you are still working for clients), you can theoretically get rid of any single client while not losing your profession. Firing your bad clients is even a smart thing to do because they demand more of your time, drain your energy, pay you badly (if at all), and don’t value your work in general. In contrast, good clients will treat you with respect, pay well and on time, come back, refer you to other clients, and make working with them a pleasant and productive experience. As an employee, you don’t have this freedom of firing your boss until you find a good one.
  • Tax advantages: As a freelancer, you start your own business. Please note that I’m not an accountant — and tax laws are different in different countries. But in Germany and many other developed nations, your small Python freelancing business usually comes with a lot of tax advantages. You can deduct many expenses from the taxes you pay, such as your Notebook, your car, your living expenses, working environment, eating outside with clients or partners, your smartphone, and so on. At the end of the year, many freelancers enjoy tax benefits worth tens of thousands of Euros. You can find a detailed tax guide here.
  • Business expertise: This advantage is maybe the most important one. As a freelancer, you gain a tremendous amount of experience in the business world. You learn to offer and sell your skills in the marketplace, you learn how to acquire clients and keep them happy, you learn how to solve problems, and you learn how to keep your books clean, invest, and manage your money. Being a freelancer gives you a lot of valuable business experiences. And even if you plan to start a more scalable business system, being a freelance developer is truly a great first step towards your goal. The business experience is a clear plus compared to other, more “nerdy” developers working only with code. The business skills will make you a more valuable person—even for established companies.
  • Paid learning: While you have to pay to learn at University—living is relatively expensive in Germany—being a freelance developer flips this situation upside down. You are getting paid for learning. As a bonus, the things you are learning are as practical as they can be. Instead of coding toy projects in University, you are coding (more or less) exciting projects with an impact on the real world. In Germany, the pay is relatively good due to the developed nature of the economy.
  • Save time in commute: Many Germans are stuck in commute for hours and hours every day. Being in commute is one of the major time killers in modern life. During a 10 year period, you’ll waste 2000-4000 hours — enough to become a master in a new topic of your choice, or writing more than ten full books and sell them on the marketplace. Commute time to work is one of the greatest inefficiencies of our society. And you, as a freelance developer, can completely eliminate it. This will make your life constantly easier, you have an unfair advantage compared to any other employee. You can spend the time on learning, recreation, or building more side businesses. You don’t even need a car (I don’t have one) which will save you hundreds of thousands of Euros throughout your lifetime (the average German employee spends 300,000 € on cars).
  • Family time: During the last 12 months being self-employed with Python, I watched my 1-year old son walking his first steps and speaking his first words. I was actually attending every single stage of his development and growth. While this often seems very normal to me, I guess that many fathers who work at big companies as employees may have missed their sons and daughters growing up. In my environment, most fathers do not have time to spend with their kids during their working days. But I have and I’m very grateful for this.
  • Competition: In Germany, there’s a seller’s market for freelance developers—demand is much higher than supply. This means that you can charge premium rates and work only on the gigs you want.

Are you already convinced that becoming a Python freelancer is the way to go for you? You are not alone. To help you with your quest, I have created the one and only Python freelancer course on the web which pushes you to Python freelancer level in a few months — starting out as a beginner coder. The course is designed to pay for itself because it will instantly increase your hourly rate on diverse freelancing platforms such as Upwork or Fiverr.

Disadvantages of Being a Freelance Programmer in Germany

  • Less stability: It’s hard to reach a stable income as a freelancer. In Germany, many people seek security above freedom. Also, if you want to buy your own home and need credit, banks usually have less trust in your ability to generate income than if you were employed.
  • Bad clients: You will get those bad clients for sure. However, in Germany this disadvantage is somehow mitigated as clients are mostly business owners that are able to pay their freelancing fees.
  • Legacy code: Germany has a lot of large and established industry players such as Bosch, Daimler, and other manufacturers. These older industries usually have older code bases as well. As a German freelance developer, you may need to handle more legacy code than as a freelancer in a newer economy such as, for example, India.
  • Solitude: If you are working as an employee at a company, you always have company, quite literally. In Germany, this culture is especially true—only a small percentage of your IT friends will work as self-employed freelance developers. Most coders work for big companies.

Freelance Developer Germany While Employed

If you’re an employee, you have the freedom to create your own side-hustle in Germany. However, there are some laws that ensure that people don’t work too much. Thus, you need to be careful not to work too many hours per week. In this resource, they recommend not to work more than 18 hours per week on your side business—if you still have a main job. In general, these are the points to consider when creating your own side-business as a freelance developer in Germany:

  • Side vs Main Income: Make sure to earn more in your main job than in your side business. This is required so that it still counts as a side-business and not your main income. In that case, your business would be considered your main income which would result in a loss of some benefits paid by your employer.
  • Inform Your Employer: You may need to inform your employer that you create your side business. This may be required by contract or even by law (for some type of jobs such as government employees).
  • Register Your Business: You need to register your business with the tax office and government. As in most other countries, you cannot just “go for it” but need to register your intent to create a business—even if it is on the side.
  • Social Insurance: If you’re creating a business on the side, you’re stilled insured by your employer (e.g., for pension funds and health insurance). That’s why you need to make sure not to work or earn too much for your side business. As soon as you cross this threshold and your “side” business becomes your primary income stream, you need to take care of insurance yourself and you’ll lose access to the benefits provided by the employer. (Well, if you reach this point, you essentially have a double income so you probably wouldn’t care financially.)
  • Tax: You need to make sure to pay all taxes (e.g., sales tax and income tax). However, suppose you don’t earn a lot with your side business. In that case, you’re probably eligible to apply for special tax treatment (“Kleinunternehmerregelung”) to free you from the need (partially) to pay sales taxes.

You can read more in this excellent online overview article.

Freelance Developer Germany Hourly Rate

Freelance developers in Germany earn more than their employed colleagues. A recent article from a German magazine states that the average freelance developer earns 84€ per hour. If you work 8 hours per day for a client, you’d earn 640€ per day or 13440€ per month.

Note that this is the average rate of a freelance developer! Most people can significantly increase their income by honing their business and programming skills at the same time—and reach above-average hourly rates over time. If you reach expert status in a certain area, you can charge 100€ per hour which results in a monthly income of 16000€.

Becoming a freelance developer in Germany is, indeed, a profitable endeavor!

Make sure to save some 10% of your income for more calm times to ensure liquidity at all costs. Cash is the lifeblood of any business and the sensible business owner makes sure to always have enough cash on their bank account to pay for at least 6 months of expenses.

To learn how to reach above-average hourly rates, join my Python freelancer course—the world’s most comprehensive and in-depth freelance developer program!

*** The Six-Figure Python Freelance Developer Course ***

Freelance Developer Germany Tax

There are two primary types of taxes for self-employed freelancers in Germany: sales tax and income tax.

  • Sales tax is between 16-18% of each transaction volume and if you sell your services to another business, you can usually deduct it again (ask your accountant)!
  • Income tax can easily reach 40% of your income if you reach the average earning levels of a German freelancer of a six-figure income.

However, if you’re just starting out and you’ve only a few or zero clients, you don’t have to pay either sales tax and income tax.

There are many ways to optimize your taxes and I recommend you check out our detailed tax guide (for hackers) to learn some smart ways to pay less tax and invest in your future success.

Freelance Developer German Language

My friend and freelancer Lukas is involved in freelancing for German clients. He’s a German guy so he swears on using a German gig description on freelancing platforms such as Fiverr. The big benefit is that, as a person being able to speak the German language, you can shield yourself from international competition and price wars. Many German clients only seek freelancers who can speak German with them because they’re uncomfortable in expressing their needs and gig specifications in a foreign language such as English. Being able to speak German well can make your freelancing business even more profitable and better protected against the competition!

Where to Go From Here?

Enough theory, let’s get some practice!

To become successful in coding, you need to get out there and solve real problems for real people. That’s how you can become a six-figure earner easily. And that’s how you polish the skills you really need in practice. After all, what’s the use of learning theory that nobody ever needs?

Practice projects is how you sharpen your saw in coding!

Do you want to become a code master by focusing on practical code projects that actually earn you money and solve problems for people?

Then become a Python freelance developer! It’s the best way of approaching the task of improving your Python skills—even if you are a complete beginner.

Join my free webinar “How to Build Your High-Income Skill Python” and watch how I grew my coding business online and how you can, too—from the comfort of your own home.

Join the free webinar now!

The post How to Be a Freelance Developer in Germany first appeared on Finxter.

Posted on Leave a comment

Writing, Running, Debugging, and Testing Code In PyCharm

How To Write Python Code In Pycharm?

Every code or file within Pycharm is written inside a project. This means, everything in PyCharm is written with respect to a Project and the first thing that you need to create before you can write any code is a project. So, let’s see how we can create a project in PyCharm.

➮ After successfully installing PyCharm, the welcome screen comes up. Click Create New Project.

The Create New Project window opens up.

✶ In this window specify the location of the project where you want to save the files.

✶ Expand the Python Interpreter menu. Here, you can specify whether you want to create a new project interpreter or reuse an existing one. From the drop-down list, you can select one of the options: Virtualenv, Pipenv, or Conda. These are the tools that help us to keep dependencies required by different projects and are separated by creating isolated Python environments for each of them. You can also specify the location of the New environment and select a Base interpreter (for example Python2.x or Python3.x) from the options available. Then we have checkboxes to select Inherit global site-packages and Make available to all projects. Usually, it is a good idea to keep the defaults.

✶ Click Create on the bottom right corner of the dialog box to create the new project.

Note: You might be notified that: Projects can either be opened in a new window or you can replace the project in the existing window or be attached to the already opened projects. How would you like to open the project? Select the desired option.

You might also get a small Tip of the Day popup where PyCharm gives you one trick to learn at each startup. Feel free to close this popup.

Now, we are all set to start writing our first Python code in PyCharm.

  • Click on File.
  • Choose New.
  • Choose Python File and provide a name for the new file. In our case we name it add. Press enter on your keyboard and your new file will be ready and you can write your code in it.

Let us write a simple code that adds two numbers and prints the result of the addition as output.

How To Run The Python Code In PyCharm?

Once the code is written, it is time to run the code. There are three ways of running the Python code in PyCharm.

Method 1: Using Shortcuts

  • Use the shortcut Ctrl+Shift+R on Mac to run the code.
  • Use the shortcut Ctrl+Shift+F10 on Windows or Linux to run the code.

Method 2: Right click the code window and click on Run ‘add’

Method 3: Choose ‘add’  and click on the little green arrow at the top right corner of the screen as shown in the diagram below.

How To Debug The Code Using Breakpoints?

While coding, you are bound to come across bugs especially if you are working with a tedious production code. PyCharm provides an effective way of debugging your code and allows you to debug your code line by line and identify exceptions or errors with ease. Let us have a look at the following example to visualize how to debug your code in PyCharm.

Example:

Output:

Note: This is a very basic example and has been just used for the purpose to guide you through the process of debugging in PyCharm. The example computes the average of two numbers but yields different results in the two print statements. A spoiler: we have not used the brackets properly which results in the wrong result in the first case. Now, we will have a look at how we can identify the same by debugging our Python code in PyCharm.

Debugging our code:

Step 1: Setting The Breakpoint

The first requirement to start debugging our code is to place a breakpoint by clicking on the blank space to the left of line number 1 ( this might vary according to your code and requirements). This is the point where the program will be suspended and the process of debugging can be started from here, one line at a time.

Step 2: Start Debugging

Once the breakpoint is set the next step is to start debugging using one of the following ways:

  • Using Shortcuts: Ctrl+Shift+D on Mac or Shift+Alt+F9 on Windows or Linux.
  • Right-click on the code and choose Debug ‘add’.
  • Choose ‘add’  and click on the icon on the top right corner of the menu bar.

Once you use any one of the above methods to start debugging your code, the Debug Window will open up at the bottom as shown in the figure below. Also, note that the current line is highlighted in blue.

Step 3: Debug line by line and identify the error (logical in our case). Press F8 on your keyboard to execute the current line and step over to the next line. To step into the function in the current line, press F7. As each statement is executed, the changes in the variables are automatically reflected in the Debugger window.

How To Test Code In PyCharm?

For any application or code to be operational, it must undergo unit test and PyCharm facilitates us with numerous testing frameworks for testing our code. The default test runner in Python is unittest, however, PyCharm also supports other testing frameworks such as pytestnosedoctesttox, and trial.

Let us create a file with the name currency.py and then test our file using unit testing.

Now, let us begin unit testing. Follow the steps given below:

Step 1: Create The Test File

To begin testing keep the currency.py file open and execute any one of the following steps:

  1. Use Shortcut: Press Shift+Cmd+T on Mac or Ctrl+Shift+T on Windows or Linux.
  2. Right-click on the class and select Go To ➠ Test. Make sure you right-click on the name of the class to avoid confusion!
  3. Go to the main menu ➠ select Navigate ➠ Select Test

Step 2: Select Create New Test and that opens up the Create Test window. Keep the defaults and select all the methods and click on OK.

✶ PyCharm will automatically create a file with the name test_currency.py with the following tests within it.

Step 3: Create the Test Cases

Once our test file is created we need to import the currency class within it and define the test cases as follows:

Step 4: Run the Unit Test

Now, we need to run the test using one of the following methods:

  • Using Shortcut: Press Ctrl+R on Mac or Shift+F10 on Windows or Linux.
  • Right-click and choose Run ‘Unittests for test_currency.py’.
  • Click on the green arrow to the left of the test class name and choose Run ‘Unittests for test_currency.py’.

You will since that two tests are successful while one test fails. To be more specific unit test for test_euro() and test_yen() are successful while the test fails for test_pound().

Output:

That brings us to the end of this section and it is time for us to move on to a very important section of our tutorial where we will be discussing numerous tips and tricks to navigate PyCharm with the help of some interesting shortcuts. We will also discuss in brief about some of the tools like Django that we can integrate with PyCharm. So, without further delay lets dive into to next section.

Please click on the Next link/button given below to move on to the next phase of PyCharm journey!






The post Writing, Running, Debugging, and Testing Code In PyCharm first appeared on Finxter.

Posted on Leave a comment

Freelance Software Development in the United States (US)

USA

The next disruption is about to happen in the freelancing space. Freelancing platforms such as Upwork and Fiverr grow double-digit per year.

But what if you’re living in the US? Is freelancing still a great opportunity for you—given the worldwide competition? How much can you earn in the US?

In this article, we’re going to answer these most common questions!

What’s the Hourly Rate of an US-Based Freelance Developer?

What’s the hourly rate of a freelance developer? If you’re like me, you want to peek into the potential of a given profession before you commit years of your life to any profession like freelance developing.

The average freelance developer in the US earns $56 per hour with conservative estimates ranging as low as $31 and aggressive estimates ranging as high as $82.

The following table compares the hourly rates of employed developers and freelance developers:

Job Description Status Hourly Rate
Web Developer Employee $31.62
Freelancer $34.78
PHP Developer Employee $46.28
Freelance $50.90
.Net Developer Employee $55.06
Freelance $60.56
Python Developer Employee $56.90
Freelance $62.59

About the Data. Our data is based on various online sources such as indeed.com, neuvoo.co.uk, and other portals where professionals can report their earnings. We state the sources below in the image captions.

We modified the expected earnings of a freelancer by increasing the average earnings of an employed professional by 10%. This is based on the findings of this study: the average freelancer earns about 10% more than his employed counterpart. We found that in practice, the difference is often much higher than that—freelancers earning much more than employees. One of the reasons may be that freelancers have more control of their earnings—an ambitious freelancer tends to earn a higher percentage more than an ambitious employee in the same profession. This is because there are no caps in freelance earnings.

If you want to earn your full-time income working in your part-time freelancing business, check out our course “Become a Python Freelance Developer”.


The average hourly rate of an employed web developer is $31.62 per hour in the US. The average hourly rate of a freelance web developer is $34.78 in the US.

The average hourly rate of an employed Python developer is $56.90 per hour in the US. The average hourly rate of a freelance Python developer is $62.59 in the US.

The average hourly rate of an employed PHP developer is $46.28 per hour in the US. The average hourly rate of a freelance PHP developer is $50.90 in the US.

The average hourly rate of an employed .Net developer is $55.06 per hour in the US. The average hourly rate of a freelance .Net developer is $60.56 in the US.

Related Article: Freelance Developer Hourly Rate By Regions and Professions

How Do You Compete with Cheap Labor Countries as an US-based Freelance Developer?

In the following video, I discuss little-known but very effective strategies to compete in a globalized economy as a US-based freelance developer.

How Many Freelance Software Developers Are There in the United States?

How many freelance developers are there in the US? There’s no official and precise answer. However, based on three credible sources—Upwork, Freelancer Union, McKinsey—I calculated an estimation stemming from each source.

Here are our estimations for the number of freelancers based on three independent data sources:

  • Upwork Data: 12,500,000 freelance developers in the IT sector.
  • Freelancer Union Data: 1,740,000 freelance developers in the IT sector.
  • McKinsey Data: 5,400,000 freelance developers in the IT sector.

The median of these three data points—Upwork, Freelancer Union, McKinsey—is 5,400,000 freelance developers working in an IT related field and the average is 6,560,000 freelance developers. Thus, the number of freelance developers is between 5 and 7 million.

A more in-depth explanation of these estimations is given in my detailed blog article.

Related Article: How Many Freelance Developers Are There in the US?

Where to Go From Here?

Enough theory, let’s get some practice!

To become successful in coding, you need to get out there and solve real problems for real people. That’s how you can become a six-figure earner easily. And that’s how you polish the skills you really need in practice. After all, what’s the use of learning theory that nobody ever needs?

Practice projects is how you sharpen your saw in coding!

Do you want to become a code master by focusing on practical code projects that actually earn you money and solve problems for people?

Then become a Python freelance developer! It’s the best way of approaching the task of improving your Python skills—even if you are a complete beginner.

Join my free webinar “How to Build Your High-Income Skill Python” and watch how I grew my coding business online and how you can, too—from the comfort of your own home.

Join the free webinar now!

The post Freelance Software Development in the United States (US) first appeared on Finxter.

Posted on Leave a comment

How Many Freelance Developers Are There in the US?

How many freelance developers are there in the US? There’s no official and precise answer. However, based on three credible sources—Upwork, Freelancer Union, McKinsey—I calculated an estimation stemming from each source.

Here are our estimations for the number of freelancers based on three independent data sources:

  • Upwork Data: 12,500,000 freelance developers in the IT sector.
  • Freelancer Union Data: 1,740,000 freelance developers in the IT sector.
  • McKinsey Data: 5,400,000 freelance developers in the IT sector.

The median of these three data points—Upwork, Freelancer Union, McKinsey—is 5,400,000 freelance developers working in an IT related field and the average is 6,560,000 freelance developers. Thus, the number of freelance developers is between 5 and 7 million.

Methodology

To come up with an exact answer on how many freelance developers there are in the US, I decided to use several independent data sources and aggregate the results. Here are the different sources used to estimate the number of freelancers in the United States.

  • Upwork: Upwork is the largest freelancing marketplace in the world.
  • Freelancer Union Report: “Freelancers Union is a non-profit organization in the United States of America. The organization provides advocacy, programming and curated insurance benefits for freelancers through partnerships.” (source)
  • McKinsey Report “Independent Work”: McKinsey funded a large-scale report about the state of the independent work sector.

Results

Upwork

  • Upwork has 18,000,000 registered freelancers in 2020. (source)
  • About 30% of the revenue is generated by US-based freelancers. (source)
  • Based on these data points, there are approximately 18,000,000 * 30% = 5,000,000 Upwork freelancers in the US.
  • There are 12 categories on Upwork—three of which are “freelance developing”: (1) IT&Networking, (2) Data Science & Analytics, (3) Web, Mobile, & Software Development.
  • Assuming an approximately equal distribution of freelancers in broad categories, the percentage of freelance developers is 3/12 = 25%.
  • Based on this, the total number of freelancers in the US on Upwork is 25% * 5,000,000 = 1,250,000.
  • The total market of freelancing is $1 trillion USD in 2020. (source)
  • Gross services volume (GSV) increased by 28% year-over-year to $1.76 billion for the full year. (source)
  • Upwork represents only a small fraction of the marketplace (although many freelance developers will have an account).
  • Assuming only 10% of all freelance developers use Upwork, the total number of freelancers in the US can be estimated as 12,500,000.

Freelancer Union Report

  • There are 58,000,000 freelancers in the US. (source)
  • 3% of all workers, freelancers or employees, are in the IT sector. (source)
  • Based on these two data points, there are at least 58,000,000 * 3% = 1,740,000 freelancers. This is very conservative estimation because the IT sector will be larger within the freelancer space than outside it.

McKinsey Report “Independent Work”

  • There are 54,000,000 million freelancers in the US. (source)
  • Approximately 10% of the income earned is done by computer and technology professions. (source)
  • As a result, there are 5,400,000 freelance developers in the US.

Summary

Here are our estimations for the number of freelancers based on three independent data sources:

  • Upwork Data: 12,500,000 freelance developers in the IT sector.
  • Freelancer Union Data: 1,740,000 freelance developers in the IT sector.
  • McKinsey Data: 5,400,000 freelance developers in the IT sector.

The median of these three data points is 5,400,000 freelance developers working in an IT related field.

The average of these three data points is 6,560,000 freelance developers working in an IT related field.

Do you want to become one of them? As it turns out, freelance developing is a profitable niche where average workers earn six figures and beyond! Check out the following resources:

Where to Go From Here?

Enough theory, let’s get some practice!

To become successful in coding, you need to get out there and solve real problems for real people. That’s how you can become a six-figure earner easily. And that’s how you polish the skills you really need in practice. After all, what’s the use of learning theory that nobody ever needs?

Practice projects is how you sharpen your saw in coding!

Do you want to become a code master by focusing on practical code projects that actually earn you money and solve problems for people?

Then become a Python freelance developer! It’s the best way of approaching the task of improving your Python skills—even if you are a complete beginner.

Join my free webinar “How to Build Your High-Income Skill Python” and watch how I grew my coding business online and how you can, too—from the comfort of your own home.

Join the free webinar now!

The post How Many Freelance Developers Are There in the US? first appeared on Finxter.

Posted on Leave a comment

Freelance Developers Specialize! But Where?

As a freelance developer, many routes lead to success. But this doesn’t mean that you shouldn’t decide which route to take and stick to it!

Quite contrarily, the worst is to be a jack-of-all-trades—a freelance developer who doesn’t have the guts to focus on one specialized skill set. Specialization is critical for your success as a freelance developer. Specialists earn more money, learn faster because they can build on knowledge they’ve already acquired, are more efficient because they don’t need to spend hours and hours learning about a new field for each gig they take, and enjoy a higher status as they’re perceived as “experts in their fields”.

In the following, you’re going to learn about the most popular niches in the freelance developing space.

Freelance Web Developer

The most popular freelance developer specialization is web developing. This makes sense because most freelancing gigs are brokered over the web. So, why not sell your skills creating websites and solving other types of problems in the web.

As a freelance web developer, you must discuss requirements with clients, propose website ideas, design web pages, fix broken databases, work with CMS, write HTML code, add JavaScript widgets, and collaborate with designers. You can focus on front-end, or back-end, or full-stack web development.

  • Front-end web development: Create websites but focus on user interfaces, usability, and design. You use front-end technologies such as JavaScript, HTML, CSS and Bootstrap.
  • Back-end web development: Create web application but focus on server-side logic—databases, scaling the application to hundreds of thousands of users, distributed systems.
  • Full-stack web development: Create web applications but be able to do both front-end and back-end web development. These highly skilled professionals are sought by many small companies that cannot afford to hire multiple web developers. Also, it helps you understand the big picture of a web application which is a vital skill for leaders and higher management.

Freelance Full Stack Developer

“A full stack web developer is a person who can develop both client and server software. In addition to mastering HTML and CSS, he/she also knows how to: Program a browser (like using JavaScript, jQuery, Angular, or Vue) Program a server (like using PHP, ASP, Python, or Node)” (source)

Freelance Frontend Developer

“A front-end web developer is responsible for implementing visual elements that users see and interact with in a web application. They are usually supported by back-end web developers, who are responsible for server-side application logic and integration of the work front-end developers do.” (source)

Freelance Backend Developer

“Back-end developers work hand-in-hand with front-end developers by providing the outward facing web application elements server-side logic. In other words, back-end developers create the logic to make the web app function properly, and they accomplish this through the use of server-side scripting languages like Ruby or.” (source)

Freelance Qt Developer

“Qt (pronounced “cute”) is a free and open-source widget toolkit for creating graphical user interfaces as well as cross-platform applications that run on various software and hardware platforms such as Linux, Windows, macOS, Android or embedded systems with little or no change in the underlying codebase while still being a native application with native capabilities and speed (source).”

As a freelance Qt developer, you create application that use Qt as a GUI framework. Qt is a widely distributed framework that is used for many Linux systems, Adobe, Google Earth, Photoshop, and many popular applications. Because of the wide distribution of the Qt framework—and the high barrier to entry—freelancing as a Qt developer can be very profitable. However, the learning curve is quite steep as well and you must be willing to read many books and spend hundreds of hours learning this exciting framework.

Freelance Quant Developer

Quants are finance geeks that use quantitative analysis to gain insight into financial data. Quants have a thorough statistical education because they must understand the statistical significance of their insights. The financial niche pays above average and you can work for large financial firms that crunch numbers to come to predictions regarding undervalued stocks or financial instruments.

The potential to work as a freelancer is relatively limited because most large financial institutions rely on quant employees. However, more and more financial startups (FinTechs) hire quant developers to create trading bots and automize financial analysis. Those startups often prefer to hire freelance quant developers.

Should you become a freelance quant developer? In my opinion, this is a financially very attractive opportunity paying much more than six-figures—but only if you’re very interested in finance and you have a knack for maths, data science, and statistics.

Freelance Software Developer

A freelance software developer is a person who professionally creates software through computer programming by selling his services to companies, organizations, or individuals in an independent contractor relationship. There are a multitude of programming languages and frameworks designed to create software—so, the niche description is still very broad and general. You must choose your specific niche in more detail. However, the term “freelance software developer” is mostly used for larger-scale software projects where the freelancer is hired on a per-project basis.

Freelance Java Developer

“Java is a class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible. It is a general-purpose programming language intended to let application developers write once, run anywhere (WORA), meaning that compiled Java code can run on all platforms that support Java without the need for recompilation.” (source)

Freelance Developer Embedded

“An embedded system is a computer system—a combination of a computer processor, computer memory, and input/output peripheral devices—that has a dedicated function within a larger mechanical or electrical system. It is embedded as part of a complete device often including electrical or electronic hardware and mechanical parts. Because an embedded system typically controls physical operations of the machine that it is embedded within, it often has real-time computing constraints. Embedded systems control many devices in common use today. Ninety-eight percent of all microprocessors manufactured are used in embedded systems.” (source)

Freelance eLearning Developer

“A Learning Engineer is someone who draws from evidence-based information about human development — including learning — and seeks to apply these results at scale, within contexts, to create affordable, reliable, data-rich learning environments.” (source)

Freelance Email Developer

“The Email Developer is responsible for design and execution of responsive design and development of email promotions ensuring that projects are completed.” (source)

Freelance eCommerce Developer

“The eCommerce developers are normally web developers with additional skills for the tools and platforms commonly used in eCommerce businesses. The main skills of an eCommerce developer should include: HTML, CSS, XML. JavaScript, Node.” (source)

Freelance ETL Developer

“An ETL Developer is an IT specialist who designs data storage systems for companies, and works to fill that system with the data that needs to be stored. ETL Developers generally work as part of a team. They are sometimes employed by a single company.” (source)

Freelance React Developer

“In a nutshell, a React developer designs and implements user-facing features for websites and applications using React.js. They are known as front-end developers, a sub-group of developers that manage everything that users see on their web browsers or applications.” (source)

Freelance Developer WordPress

“WordPress Developers are responsible for both back-end and front-end development, including creating WordPress themes and plugins. They have different programming skills such as namely PHP, HTML5, CSS3, and JavaScript.” (source)

Freelance Tableau Developer

“A Tableau developer creates computer system and data visualization solutions to improve business processes. This job involves tasks such as creating Tableau dashboard reports, working with developers, creating business intelligence reports and visualizations, and attending feedback sessions to improve systems.” (source)

Freelance Tally Developer

A Tally Developer uses a comprehensive development suite to develop, and deploy solutions for Tally. “Tally is a windows-based Enterprise Resource Planning software. The software handles Accounting, Inventory Management, Order Management, Tax Management, Payroll, Banking and many such requirements of the business. It supports all day-to-day processes from recording invoices to generating various MIS reports.” (source)

Freelance Zoho Developer

As a Zoho Developer, you create apps on the Zoho Developer platform that “is a free cloud platform for developers to create ready-to-deploy cloud applications on top of the Zoho platform. Unlike conventional cloud platforms, the Zoho Developer Console lets you quickly build enterprise level applications through drag and drop tools.” (source)

Freelance Unity Developer

“A unity developer creates apps for the unity platform. “Unity is a cross-platform game engine developed by Unity Technologies, first announced and released in June 2005 at Apple Inc.’s Worldwide Developers Conference as a Mac OS X-exclusive game engine. As of 2018, the engine had been extended to support more than 25 platforms.” (source)

Freelance UI Developer

A UI developer creates user interfaces to interact with the user of a given application. “Marketable programming skills for UI developers include HTML, CSS, JavaScript, AJAX, JSON, jQuery, Java, Ruby on Rails, and SQL database development. UI devs will also benefit from learning Photoshop, Flash, Flex and Illustrator from the Adobe Creative Suite.” (source)

Freelance Unreal Developer

An Unreal Developer creates apps for the Unreal engine. “Unreal Engine is the world’s most open and advanced real-time 3D creation platform for photoreal visuals and immersive experiences.” (source)

Freelance Umbraco Developer

An Umraco Developer works with the Umbraco platform, maintains it, and extends it with new features. “Umbraco is an open-source content management system (CMS) platform for publishing content on the World Wide Web and intranets. It is written in C# and deployed on Microsoft based infrastructure. Since version 4.5, the whole system has been available under an MIT License.” (source)

Freelance Flutter Developer

A Flutter Developer creates apps for the Flutter platform. “Flutter is Google’s UI toolkit for building beautiful, natively compiled applications for mobile, web, and desktop from a single codebase.” (source)

Freelance Filemaker Developer

“The primary qualifications for a FileMaker developer include experience with FileMaker database solutions, knowledge of database administration, and skills in related programming languages such as SQL, Java, and Perl.” (source)

Freelance Firmware Developer

“Firmware engineers develop the software that manages electronic devices. These positions require proficiency in programming languages and applications, as well as good communications skills.” (source)

Freelance Flask Developer

A Flask Developer is a programmer who develops apps in Python’s Flask framework. “Flask is a micro web framework written in Python. It is classified as a microframework because it does not require particular tools or libraries. It has no database abstraction layer, form validation, or any other components where pre-existing third-party libraries provide common functions. However, Flask supports extensions that can add application features as if they were implemented in Flask itself. Extensions exist for object-relational mappers, form validation, upload handling, various open authentication technologies and several common framework related tools.” (source)

Freelance Django Developer

A Django developer creates, maintains, and improves apps written in Python’s Django framework. “Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. Built by experienced developers, it takes care of much of the hassle of Web development, so you can focus on writing your app without needing to reinvent the wheel. It’s free and open source.” (source)

Freelance Game Developer

“Game developers are people like you with math, computer, or creative arts skills. They spend their time programming and developing games. This includes programming console, computer, and mobile video games. They are persistent, they are a little bit lucky, and they manage to get hired to do develop video games.” (source)

Freelance Go Developer

A Go Developer is a programmer who uses the Golang programming language to create, maintain, and improve Go applictions. “Go is a really flexible language, able to solve a lot of problems. You can use it for system and network programming, big data, machine learning, audio and video editing, and more.” (source)

Freelance GIS Developer

“The job of a geographic information systems developer is to design and execute applications used to support GIS data; “GIS” refers simply to applications and software which collect data from specific locations. The applications developed by those in this position are also used to edit and analyze data and create maps.” (source)

Freelance Hubspot Developer

A Hubspot developer is involved in managing access to the HubAPI. “This domain is owned by Hubspot. The company provides a range of online marketing and sales technology and services. The main purpose of cookies set by this host is: Targeting/Advertising.” (source)

Freelance HTML Developer

“HTML developers are responsible for the complete end-to-end coding of websites. They provide technical support to website users, direct HTML projects, code sites, develop web-based applications, and perform testing on Web sites and their background code.” (source)

Freelance LabVIEW Developer

A Labview developer has passed the LabVIEW exam. “The Certified LabVIEW Developer (CLD) exam verifies the user’s ability to design and develop functional programs while minimizing development time and ensuring maintainability through proper documentation and style. Certified Developers can provide technical leadership to less experienced engineers, helping ensure their team is following best practices and becoming more competent and efficient LabVIEW programmers.” (source)

Freelance VR Developer

A VR developer specializes in virtual reality. In particular, the VR developer is involved in “development of VR and AR applications (UE4, Unity, C++, C#), development and implementation of prototypes and new functions, agile development planning, and running tests and code reviews.” (source)

Freelance VBA Developer

“A VBA Developer works with the Excel application and adapts it to the specific needs of a challenge or requirements to automate repetitive tasks and accelerate the workflow of a business. This is done using the Visual Basic for Applications and Macros – hence the term VBA developer.” (source)

Freelance UI Developer

“A UI developer’s role is to translate creative software design concepts and ideas into reality using front end technology. They understand the user interface design solution both in its practical intent and creative vision, and convert it into engineered softwares.” (source)

Freelance Blockchain Developer

“A developer responsible for developing and optimizing blockchain protocols, crafting the architecture of blockchain systems, developing smart contracts and web apps using blockchain technology are commonly called blockchain developers.” (source)

Freelance .Net Developer

“A .NET Software Developer is a software developer who specialises in building software for Microsoft’s Windows platform. They work with programming languages compatible with Microsoft’s .NET framework, including VB.NET, C# (C sharp) and F# (F sharp).” (source)

Freelance Mobile Developer

“Mobile developers are a type of software developer. They specialise in mobile technology such as building apps for Google’s Android, Apple’s iOS and Microsoft’s Windows Phone platforms. For this reason job titles for this type of role also include Android developer and iOS developer.” (source)

Freelance Magento Developer

“Magento developers are in charge of developing, maintaining, and improving their clients’ eCommerce websites. … Magento developers are in charge of developing, maintaining, and improving their clients’ eCommerce websites. Their responsibility is huge, as most of the time, Magento websites generate a lot of revenue.” (source)

Freelance iOS Developer

“An iOS developer is responsible for developing applications for mobile devices powered by Apple’s iOS operating system. Ideally, a good iOS developer is proficient with one of the two programming languages for this platform: Objective-C or Swift.” (source)

Freelance IONIC Developer

An IONIC developer creates apps for the IONIC platform. “Ionic provides tools and services for developing hybrid mobile, desktop, and Progressive Web Apps based on modern web development technologies and practices, using Web technologies like CSS, HTML5, and Sass. In particular, mobile apps can be built with these Web technologies and then distributed through native app stores to be installed on devices by utilizing Cordova or Capacitor.” (source)

Freelance Odoo Developer

An Odoo developer is involved in Odoo development. “Odoo is a suite of business management software tools including CRM, e-commerce, billing, accounting, manufacturing, warehouse, project management, and inventory management to name a few.” (source)

Freelance Outsystems Developer

An Outsystems Developer creates and ships scalable, responsive software developed with OutSystems. The rapidly developed apps integrate well with existing systems and possess high scalability.

Freelance App Developer

“An app developer is a computer software engineer whose primary responsibilities include creating, testing and programming apps for computers, mobile phones, and tablets. These developers typically work in teams, and think of ideas and concepts either for the general public, or for a specific customer need.” (source)

Freelance Android Developer

An Android developer creates mobile applications for the Android operating system. “You can make a very competitive income, and build a very satisfying career as an Android developer. Android is still the most used mobile operating system in the world, and the demand for skilled Android developers remains very high.” (source)

Freelance Angular Developer

An Angular developer is involved in the following activities: “Designing and developing user interfaces using AngularJS best practices. Adapting interface for modern internet applications using the latest front-end technologies. Writing JavaScript, CSS, and HTML. … Ensuring high performance of applications and providing support.” (source)

Freelance Database Developer

“Database developers ensure that database management systems (DBMS) can handle massive quantities of data. Also called database programmers, developers usually work as part of a software development team. … Modifying and editing databases. Designing and developing new databases.” (source)

Freelance Drupal Developer

“A Drupal developer is someone who writes a lot of PHP and other server side languages. They write custom modules, automated tests, consume web services, automate deployment etc. They may also be know as “backend Drupal developers”. They may also get involved in some of the more advanced side of the theme layer as well.” (source)

Freelance Delphi Developer

A Delphi developer creates code in the Delphi programming language. “Delphi is a high-level programming language distributed by Embarcadero Technologies as part of RAD Studio, an IDE for professional developers. It is primarily used to build applications for Windows systems but can be used to build applications for a variety of operating systems.” (source)

Freelance Oracle Developer

“An Oracle developer is responsible for creating or maintaining the database components of an application that uses the Oracle technology stack. Oracle developers either develop new applications or convert existing applications to run in an Oracle Database environment.” (source)


Do you want to develop the skills of a well-rounded Python professional—while getting paid in the process? Become a Python freelancer and order your book Leaving the Rat Race with Python on Amazon (Kindle/Print)!

Leaving the Rat Race with Python Book

Where to Go From Here?

Enough theory, let’s get some practice!

To become successful in coding, you need to get out there and solve real problems for real people. That’s how you can become a six-figure earner easily. And that’s how you polish the skills you really need in practice. After all, what’s the use of learning theory that nobody ever needs?

Practice projects is how you sharpen your saw in coding!

Do you want to become a code master by focusing on practical code projects that actually earn you money and solve problems for people?

Then become a Python freelance developer! It’s the best way of approaching the task of improving your Python skills—even if you are a complete beginner.

Join my free webinar “How to Build Your High-Income Skill Python” and watch how I grew my coding business online and how you can, too—from the comfort of your own home.

Join the free webinar now!

The post Freelance Developers Specialize! But Where? first appeared on Finxter.

Posted on Leave a comment

Overriding in Python

In this article, we are going to explore the concept of overriding in Python. We are also going to explore what are magic methods and abstract classes.

Introduction

Overriding is an interesting concept in object-oriented programming.  When the method definitions of a Base Class are changed in a Subclass (Derived) Class this is called a method override.  You are keeping the same signature of the method but changing the definition or implementation of a method defined by one of the ancestors.  There is no special syntax or additional keywords needed to do method overriding in Python.  It is a very important object-oriented programming concept since it makes inheritance exploit its full power.  In essence, you are not duplicating code, thus following the programming principle of DRY (do not repeat yourself), and you can enhance the method in the subclass.

To understand the concept of overrides, you must know the basic concepts of object-oriented programming such as classes and inheritance.  There are many resources on the internet about OOP.  A really good resource is Finxter Academy’s object-oriented Python class: https://academy.finxter.com/university/object-oriented-python/

Need for Overrides

In the following example, you see how inheritance works and the problem of not overriding a method in the subclass.  The Parent class has a method whoami that displays “I am a parent”.  This method is inherited by the Child class.  Calling the whoami method from the Child class, calls the inherited method from the Parent class and thus displays “I am a parent” which is wrong.

Inheritance example with no method overriding:

class Parent(): def whoami(self): print("I am a parent") class Child(Parent): def play(self): print(" I am playing") child = Child()
child.whoami() # Output:
# I am a parent

Basic Override

The next example, shows how basic overriding works.  In this example the Child class has a definition of the whoami method that overrides the method from the Parent class. Calling the whoami method from the Child class now displays “I am a child”.

Basic Overriding example:

#Overriding
class Parent(): def whoami(self): print("I am a parent") class Child(Parent): def play(self): print(" I am playing") def whoami(self): print("I am a child") parent = Parent()
parent.whoami()
print()
child = Child()
child.whoami() # Output:
# I am a parent
# I am a child

Extending a Method Through Overrides

The third example shows how you can extend a method in a Base Class by overriding the method in the Subclass.  To do that we use the super() built-in function.  It returns a proxy object that allows us to access methods of the base class.  We can refer to the base class from the subclass without having to call the base class name explicitly.

The Employee class has the following details for the employee: employee number, employee name, salary and, department number.  This information is passed to the instantiated object in the __init__ method.  The showEmployee method of the class then displays this information formatted using new lines.

The Salesman class inherits from the Employee class.  By default, it inherits the showEmployee method as-is from the Employee class.  The only problem is that we want to display the commission that the salesman receives as part of the printed information.  Here is where overriding is needed.  We want to reuse the showEmployee method from the Employee class but we want to extend it to add the commission information.  This is accomplished by using the super() built-in function.  In the example below you see that in the Salesman class, super() is used twice.  The __init__ method uses it to call the __init__ method of the Employee base class and the showEmployee uses it to override the showEmployee method of the Employee base class.  In it, we display the employee information for the salesman plus the commission for the salesman.

A third class called CEO uses the same logic as before.  The showEmployee method in this case displays the employee information plus the stock options for the CEO.

class Employee(): def __init__(self, empno, ename, salary, deptno): self.Empno = empno self.Ename = ename self.Salary = salary self.Deptno = deptno def showEmployee(self): print("Employee # : {}\nEmployee Name : {}\nSalary : {}\nDepartment : {}".format(self.Empno, self.Ename, self.Salary, self.Deptno)) class Salesman(Employee): def __init__(self, empno, ename, salary, deptno, comm): self.Commission = comm super().__init__(empno, ename, salary, deptno) def showEmployee(self): print("Salesman Profile") super().showEmployee() print("Commision : ", self.Commission) class CEO(Employee): def __init__(self, empno, ename, salary, deptno, stock): self.Stock = stock super().__init__(empno, ename, salary, deptno) def showEmployee(self): print("CEO Profile") super().showEmployee() print("Stock Options : ", self.Stock) salesman = Salesman(200, "John Doe", 67000, "Sales", 100)
salesman.showEmployee()
print("")
ceo = CEO(40, "Jennifer Smith", 300000, "Director", 1000000)
ceo.showEmployee() 

Output:

Salesman Profile
Employee # : 200
Employee Name : John Doe
Salary : 67000
Department : Sales
Commision : 100 CEO Profile
Employee # : 40
Employee Name : Jennifer Smith
Salary : 300000
Department : Director
Stock Options : 1000000

Multiple Inheritance Overriding

Understanding multiple inheritance has its own challenges.  One of them is the use of super().  Here is a link to an article about this issue: https://www.datacamp.com/community/tutorials/super-multiple-inheritance-diamond-problem

In the example below, I wanted to show a way to override a method from a subclass with multiple inheritance.  The example consists of three classes: Account, Customer, and Orders

  • The Account class has its name and number and a display method which displays this information. 
  • The Customer class has also its name and number and a display method that displays this information. 
  • The Orders class displays the orders information for a customer in a specific account.  It inherits from both the Account and Orders class.  The display method in this class overrides the display methods of the base classes.  The display method prints the Account information, the Customer information, and the Orders information

Here’s an example:

class Account(): def __init__(self, name, number): self.Name = name self.Number = number def display(self): print("Account # : {}\nAccount Name : {}".format(self.Number, self.Name)) class Customer(): def __init__(self, name, number): self.Name = name self.Number = number def display(self): print("Customer # : {}\nCustomer Name : {}".format(self.Number, self.Name)) class Orders(Account, Customer): def __init__(self, acctnumber, acctname, custnumber, custname, ordnumber, ordnamename, product, qty): self.OrdNumber = ordnumber self.Product = product self.Qty = qty self.OrdName = ordnamename self.acct = Account(acctname, acctnumber) self.cust = Customer(custname, custnumber) def display(self): print("Order Information") self.acct.display() self.cust.display() print("Order # : {}\nOrder Name : {}\nProduct : {}\nQuantiy : {}".format(self.OrdNumber, self.OrdName, self.Product, self.Qty)) acct = Account("AB Enterprise", 12345)
acct.display()
print("")
cust = Customer("John Smith", 45678)
cust.display()
print("")
order = Orders(12345, "AB Enterprise", 45678,"John Smith", 1, "Order 1", "Widget", 5, )
order.display()

Output:

Account # : 12345
Account Name : AB Enterprise Customer # : 45678
Customer Name : John Smith Order Information
Account # : 12345
Account Name : AB Enterprise
Customer # : 45678
Customer Name : John Smith
Order # : 1
Order Name : Order 1
Product : Widget
Quantiy : 5

Different Overriding Scenarios

1 – Class Methods

Class methods are special in the sense that they can be called on a class by itself or by instances of a class.  They bind to a class so this means that the first argument passed to the method is a class rather than an instance.

Class methods are written similarly to regular instance methods.  One difference is the use of the decorator @classmethod to identify that the method is a class method.  Also, by convention, instead of using self to reference the instance of a class, cls is using to reference the class.  For example:

class Account(): @classmethod def getClassVersion(cls): print("Account class version is 1.0”)

For more information about class methods check this website.

Here is an example of the problem you will encounter when overriding a class method:

class ParentClass: @classmethod def display(cls, arg): print("ParentClass") class SubClass(ParentClass): @classmethod def display(cls, arg): ret = ParentClass.create(cls, arg) print("Subclass") return ret SubClass.display("test")

Output:

create() takes 2 positional arguments but 3 were given

In the Subclass, the call to the ParentClass create method is not an unbound call the way it happens with a normal instance method.  The outcome of this call is a TypeError because the method received too many arguments.

The solution is to use super() in order to successfully use the parent implementation.

class ParentClass: @classmethod def display(cls, arg): print("ParentClass") class SubClass(ParentClass): @classmethod def display(cls, arg): ret = super(SubClass, cls).create(arg) print("Subclass") return ret SubClass.display("test")

Output:

ParentClass
Subclass

2 – Magic Methods

What are magic methods?

Magic methods are a set of methods that Python automatically associates with every class definition. Your classes can override these magic methods to implement different behaviors and make them act just like Python’s built-in classes. Below you will see examples of two of the most common ones: __str__ and __repl__. Using these two methods, you can implement how your objects are displayed as strings, which will be of importance while debugging and presenting the information to the user.  Overriding these methods adds to the flexibility and power of Python.  

The __str__ method of a class is used when Python prints an object. This magic method is called by the str built-in function.

class DemoMagic(): def display(self): print("Demo Magic class") varDemo = DemoMagic()
varDemo.display()
str(varDemo) 

Output:

Demo Magic class '<__main__.DemoMagic object at 0x000002A7A7F64408>' class DemoMagic():
def display(self): print("Demo Magic class") def __str__(self): return "Override of str function" varDemo = DemoMagic()
varDemo.display()
str(varDemo) 

Output:

Demo Magic class 'Override of str function'

The __repr__ method of a class is used to display the details of an object’s values. This magic method is called by the built-in the repr function.

class Person(object): def __init__(self, firstname, lastname): self.first = firstname self.last = lastname def __repr__(self): return "%s %s" % (self.first, self.last) Tom = Person("Tom", "Sawyer")
repr(Tom)

Output

'Tom Sawyer'

Here is a list of magic methods.  You can learn more about them here (https://www.tutorialsteacher.com/python/magic-methods-in-python) and think how to override them to fit your needs:

'__abs__', '__add__', '__and__', '__bool__', '__ceil__', '__class__', '__delattr__', '__dir__', '__divmod__', '__doc__', '__eq__', '__float__', '__floor__', '__floordiv__', '__format__', '__ge__', '__getattribute__', '__getnewargs__', '__gt__', '__hash__', '__index__', '__init__', '__init_subclass__', '__int__', '__invert__', '__le__', '__lshift__', '__lt__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__round__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__trunc__', '__xor__'

3 – Abstract Classes  

An abstract class is a blueprint that subclasses must follow.  It can be viewed as a contract between the abstract class and the subclass.  The abstract class tells you what to do by providing an empty abstract method and the subclass must implement it.  By default, you must override the abstract methods defined by the abstract class.  In other terms, we are providing a common interface for different implementations of a class.  This is very useful for large projects where certain functionality must be implemented.

Here is an example of an abstract class and the overrriden methods in the subclasses.

from abc import ABC, abstractmethod class Animal(ABC): @abstractmethod def whoami(self): pass class Dog(Animal): def move(self): print("I am a dog") class Cat(Animal): def move(self): print("I am a cat") 

Conclusion

Overriding is a basic concept used in many places in object-oriented programming.  You must understand it to be able to implement better classes and modify their behavior.  This article shows you some examples where you can use overrides in Python.  Other concepts mentioned that are worth learning more about are: magic method and abstract classes.

The post Overriding in Python first appeared on Finxter.

Posted on Leave a comment

Freelance Developer LLC — Is It Smart For You?

Should you create an LLC as a freelance developer?

In this article, you’ll learn about which clothes your freelancing business should wear. Make no mistake—choosing the right business entity matters. And informing about this question by reading articles like this one may be one of the most important decisions in your professional life.

Disclaimer: I’m not an accountant but a programmer—so, you should consult with your accountant or lawyer before taking any conclusive action!

Definition LLC

“A limited liability company (LLC) is a business structure in the United States whereby the owners are not personally liable for the company’s debts or liabilities. Limited liability companies are hybrid entities that combine the characteristics of a corporation with those of a partnership or sole proprietorship.” (source)

So, if you create an LLC, you are generally not liable for any debt or liabilities of your freelancing business. Most likely, your freelancing business doesn’t need a lot of debt—after all, you’re selling your time for money—however, there may still be liabilities!

For example, you may have signed a contract that requires you to pay for all damages incurred by your software. Yes, you shouldn’t have done it—but assuming you have, if you signed in the name of the LLC, you personally cannot be hold accountable for the potentially devastating liabilities.

Pros vs Cons Table

What are some advantages and disadvantages of a liability?

LLC Pros LLC Cons
Limited Liability – If you keep your finances separate and fullfil your duties as a business owner, you cannot be personally held liable. Your personal assets like real estate, stocks, bonds, mutual funds will remain protected even if your business fails. Limitations of Limited Liability – this is called “piercing the corporate veil” and it means that if you don’t follow the rules of the LLC, a judge may decide that your liability protection will be removed and you, personally, can be held liable.
Pass-Through Federal Taxation on Profits – Per default, the profits are not taxed on the company level but are passed through to its owners who then tax them individually. This is an advantage if you have a relatively lower tax rate and it avoids double taxation on the corporate and individual level. Self-Employment Tax – Per default, you must pay self-employment taxes on the profits of an LLC because it is a pass-through entity.
Management Flexibility – The LLC can be managed by one or more owners. This is a perfect structure for partnerships where ownership percentages can be divided in a flexible way. Turnover – If an LLC partner dies, goes bankrupt, or leaves the company, the company will be dissolved. You need to create a new one and you take over all the leaving partners’ obligations that result in dissolving the LLC.
Easy Startup Overhead – It’s relatively simple and cheap—a few hundred dollars—to start an LLC. For the amount of protection it offers, it’s a very cheap way to organize your freelancing business. Investments – It’s difficult to raise outside capital. This is usually not a problem for you as a freelance developer because freelance developing has only minimal capital requirements.
Unproportional Profit Distribution – Members can receive profits that are not proportional to the ownership percentage they hold. This allows you to reinforce members for great work.
Credibility – Being an LLC gives you more credibility as a freelance developer. Clients tend to trust you more, as a freelance developer organized in an LLC, for two reasons: you’re an US-based business and you’re a serious business.

Sources:

Freelancer LLC Taxes

An LLC isn’t a federal tax designation but there’s a pass-through federal taxation on profits. This means that in most states, LLC aren’t taxed at all but the individuals who own them are. In other words, your tax designation is that of a disregarded entity that files taxes the same as a sole proprietor.

As a freelance developer, you probably don’t want to leave a lot of profits in the business, so the fact that it is pass-through doesn’t bother you at all. If you would like to build a business machine based on smart reinvestments of profits, feel free to read my detailed article about the topic or watch the following video:

Sources:

Freelancer LLC or Sole Proprietorship

Sole proprietorship is the freelancer’s default business entity. If you don’t explicitly form an LLC or corporation, you’ll automatically operate as a sole proprietor. The main advantage of LLCs compared to Sole Proprietorships are that you’re generally not liable for debts or liabilities of your freelancing business. This protects your personal assets and reduces the likelihood of a personal bankruptcy in case of unforeseen liabilities that happened because of your business activities.

You can read more about the best legal entity for your freelancing business here.

Freelancer LLC or S-Corp

Per default, single-member LLCs are automatically taxed like sole proprietors as pass-through entities. The business isn’t taxed but you are. The S-Corp is just an alternative way you can choose to get taxed: You ask the IRS to tax your single-member LLC as an S-Corp. As a result, you don’t have to pay self-employment taxes anymore—but only income taxes on the corporate profits. This has a few advantages such as the tax deductability of the self-employment tax from corporate profits and the possibility to tax only a smaller portion of the overall profits.

You can read more in this excellent article:

Source: https://www.collective.com/blog/business-setup/llc-vs-s-corp-which-is-the-best-for-freelancers/

Freelancer LLC Names

As a freelance developer, you need to decide on a business name. There are two types of restrictions: First, you cannot choose names that are already trademarked—or that are similar to trademarked names. Second, you cannot choose names that are already taken by other businesses. If you choose your business as your personal name, you usually don’t run into any legal problem. Some people argue that this can harm your scalability or prospects to sell the business. However, as a freelance developer, this is usually not a problem as you’d create a separate business for more scalable ventures anyways.

Delaware LLC Freelancer

Can you create a Delaware corporation as a freelance developer? According to international tax lawyer Jason Knott, the answer is: “Yes, a nonresident can form an entity in Delaware or almost any other state in the U.S.” If you succeed as a freelance developer creating a Delaware LLC, you reduce or even eliminate your income tax burden. However, this can be a complicated legal procedure and you should definitely seek expert advice.

Where to Go From Here?

Enough theory, let’s get some practice!

To become successful in coding, you need to get out there and solve real problems for real people. That’s how you can become a six-figure earner easily. And that’s how you polish the skills you really need in practice. After all, what’s the use of learning theory that nobody ever needs?

Practice projects is how you sharpen your saw in coding!

Do you want to become a code master by focusing on practical code projects that actually earn you money and solve problems for people?

Then become a Python freelance developer! It’s the best way of approaching the task of improving your Python skills—even if you are a complete beginner.

Join my free webinar “How to Build Your High-Income Skill Python” and watch how I grew my coding business online and how you can, too—from the comfort of your own home.

Join the free webinar now!

The post Freelance Developer LLC — Is It Smart For You? first appeared on Finxter.

Posted on Leave a comment

How to Install PIL/Pillow in Python? A Helpful Illustrated Guide

PIL is an abbreviation of Python Imaging Library and it adds image processing to Python. In 2011, PIL has been discontinued—its unofficial successor framework Pillow for image processing is an actively maintained and user-friendly alternative for Python 3.

Install Pillow Command Line Windows
pip install Pillow

Let’s dive into the installation guides for the different operating systems and environments!

How to Install Pillow on Windows?

To install the updated Pillow framework on your Windows machine, run the following code in your command line or Powershell:

python3 -m pip install --upgrade pip
python3 -m pip install --upgrade Pillow

How to Install Pillow on Mac?

Open Terminal (Applications/Terminal) and run:

  • xcode-select -install (You will be prompted to install the Xcode Command Line Tools)
  • sudo easy_install pip
  • sudo pip install pillow
  • pip install pillow

As an alternative, you can also run the following two commands to update pip and install the Pillow library:

python3 -m pip install --upgrade pip
python3 -m pip install --upgrade Pillow

How to Install Pillow on Linux?

Upgrade pip and install the Pillow library using the following two commands, one after the other:

python3 -m pip install --upgrade pip
python3 -m pip install --upgrade Pillow

How to Install Pillow on Ubuntu?

Upgrade pip and install the Pillow library using the following two commands, one after the other:

python3 -m pip install --upgrade pip
python3 -m pip install --upgrade Pillow

How to Install Pillow in PyCharm?

The simplest way to install Pillow in PyCharm is to open the terminal tab and run the following command:

pip install Pillow

Here’s a screenshot with the two steps:

  • Open Terminal tab in Pycharm
  • Run pip install Pillow in the terminal to install Pillow in a virtual environment.
Install Pillow

As an alternative, you can also search for Pillow in the package manager. However, this is usually an inferior way to install packages because it involves more steps.

How to Install Pillow in Anaconda?

You can install the Pillow package with Conda using the following command in your shell:

 conda install -c anaconda pillow 

This assumes you’ve already installed conda on your computer. If you haven’t check out the installation steps on the official page.

Where to Go From Here?

Enough theory, let’s get some practice!

To become successful in coding, you need to get out there and solve real problems for real people. That’s how you can become a six-figure earner easily. And that’s how you polish the skills you really need in practice. After all, what’s the use of learning theory that nobody ever needs?

Practice projects is how you sharpen your saw in coding!

Do you want to become a code master by focusing on practical code projects that actually earn you money and solve problems for people?

Then become a Python freelance developer! It’s the best way of approaching the task of improving your Python skills—even if you are a complete beginner.

Join my free webinar “How to Build Your High-Income Skill Python” and watch how I grew my coding business online and how you can, too—from the comfort of your own home.

Join the free webinar now!

The post How to Install PIL/Pillow in Python? A Helpful Illustrated Guide first appeared on Finxter.