Anaconda is the data science platform for data scientists, IT professionals, and business leaders of tomorrow. It is a distribution of Python, R, etc. With more than 300 packages for data science, it becomes one of the best platforms for any project. In this python anaconda tutorial, we will discuss how we can use anaconda for python programming. The following are the topics covered in this blog:
Introduction to
- installing and configuring
- Anaconda How to install Python libraries on Anaconda?
-
- Use Case Python Fundamentals Analysis
- Machine Learning and Artificial Intelligence
- Introduction to
Anaconda Browser
Anaconda
Anaconda
is an open source distribution for python and R. It is used for data science, machine learning, deep learning, etc. With the availability of more than 300 libraries for data science, it becomes quite optimal for any programmer to work on anaconda for data science.
Choose a version suitable for you and click download. Once you complete the download, open the settings.
<img src="https://d1jnx9ba8s6j9r.cloudfront.net/blog/wp-content/uploads/2019/07/2019-07-23-17_35_23-Window.png" alt="anaconda
home-python anaconda tutorial-edureka” />
Follow the setup instructions. Don’t forget to click add anaconda to my path environment variable. After the installation is complete, you will get a window as shown in the image below.
After finishing the installation, open anaconda prompt and type jupyter notebook.
You will see a window as it is Shown in the image below.
<img src="https://d1jnx9ba8s6j9r.cloudfront.net/blog/wp-content/uploads/2019/07/2019-07-23-17_46_12-Window.png" alt="anaconda prompt – python anaconda
tutorial-edureka” />
Now that we know how to use anaconda for python let’s take a look at how we can install various libraries in anaconda for any project
.
How to install Python libraries on Anaconda? Open the anaconda
prompt and check if the library is already installed or not.
Since there is no module named numpy present, we will run the following command to install numpy.
You will get the window shown in the image once you complete the installation.
Once you have installed a library, simply try importing the module again for added security.
As you can see, there is no error we got at the beginning, this is how we can install various libraries in anaconda.
anaconda
Navigator
Anaconda
Navigator is a desktop GUI that comes with the anaconda distribution. It allows us to launch applications and manage conda, environment and packages without using command line commands.
Use Case – Python Fundamentals
Variables
and data
types Variables and data types are the building blocks of any programming language. Python has 6 types of data depending on the properties they possess. List, dictionary, set, tuple, are the collection data types in the python programming language.
Below is an example to show how variables and data types are used in python.
#variable declaration name = “Edureka” f = 1991 print(“python was founded in” , f) #data types a = [1,2,3,4,5,6,7] b = {1 : ‘edureka’ , 2: ‘python’} c = (1,2,3,4,5) d = {1,2,3,4,5} print(“the list is” , a) print(“the dictionary is” , b) print(“the tuple is” , c) print(“the set is ” , d)
Operators
Operators in Python are used for operations between values or variables. There are 7 types of operators in python.
- Assignment
- Arithmetic
- comparison
- Bit-wise
- Operator Identity Operator Below
operator
operator Logical operator Operator
operator Operator membership
is an example with the use of some operators in python.
a = 10 b = 15 #arithmetic operator print(a + b) print(a – b) print(a * b) #assignment operator a += 10 print #comparison operator #a != 10 #b == an operator #logical > b and a > 10 #this will return true if both statements are true.
Control instructions
Instructions such as if, otherwise, break, continue are used as a control instruction to gain control over execution for optimal results. We can use these statements in various loops in python to control the result. Below is an example to show how we can work with control statements and conditionals.
name = ‘edureka’ for i in name: if i == ‘a’: break else: print(i)
Functions
Python functions provide code reuse in an efficient way, where we can write the logic for a problem statement and execute some arguments to get the optimal solutions. Below is an example of how we can use functions in python.
def func(a): return a ** a res = func(10) print(res)
Classes
and objects
Since Python supports object-oriented programming, we can also work with classes and objects. Below is an example of how we can work with classes and objects in python.
class Parent: def func(self): print(‘this is parent’) class Child(Parent): def func1(self): print(‘this is child’) ob = new Child() ob.func()
Here are some fundamental concepts in python to get you started. Now talking about the support of larger packages in anaconda, we can work with many libraries. Let’s take a look at how we can use python anaconda for data analysis.
Use Case – Analytics
These are certain steps involved in data analysis. Let’s take a look at how data analysis works in anaconda and various libraries we can use.
Data collection
Data collection is as simple as loading a CSV file into the program. We can then make use of the relevant data to analyze particular instances or inputs in the data. The following is the code to load the CSV data into the program.
import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns df = pd.read_csv(‘filename.csv’) print(df.head(5))
Slicing And Dicing
After loading the dataset into the
program, we must filter the data with some changes such as removing null values and unnecessary fields that can cause ambiguity in the analysis.
Below is an example of how we can filter the data according to requirements.
print(df.isnull().sum()) will #this sum all null values in the dataset. df1 = df.dropna(axis=0 , how= ‘any’) will #this delete null rows.
<img
src=”https://d1jnx9ba8s6j9r.cloudfront.net/blog/wp-content/uploads/2019/07/5-1.png” alt=”” />
We can also remove null values
.
BoxPlot
sns.boxplot(x=df[‘Salary range from’]) sns.boxplot(x=df[‘Salary range a’])
<img src
=”https://d1jnx9ba8s6j9r.cloudfront.net/blog/wp-content/uploads/2019/07/bp.png” alt=”” />
ScatterPlot
import matplotlib.pyplot as plt fig, ax = plt.subplots(figsize=(16,8)) ax.scatter(df[‘Salary Range From’] , df[‘Salary Range To’]) ax.set_xlabel(‘Salary Range From’) ax.set_ylabel(‘Salary Range TO’) plt.show()
Visualization
Once we have changed the data according to the requirements, it is necessary to analyze this data. One such way to do this is by visualizing the results. A better visual representation helps in an optimal analysis of data projections.
Below is an example for visualizing the data.
sns.countplot(x= “Full-time/part-time indicator” , data= df) sns.countplot(x=”Full-time/part-time indicator” , hue=”Salary frequency” , data= df) sns.countplot(hue=”Full-time/part-time indicator”, x=”Publication type” ,data= df) df[“Salary range from”].plot.hist() df[“Salary range to”].plot.hist()
<img
src=”https://d1jnx9ba8s6j9r.cloudfront.net/blog/wp-content/uploads/2019/07/new1.png” alt=”” />
<img src
=”https://d1jnx9ba8s6j9r.cloudfront.net/blog/wp-content/uploads/2019/07/3-3.png”
alt=”
” /> import matplotlib.pyplot as plt fig = plt.figure(figsize = (10,10)) ax = fig.gca() sns.heatmap(df1.corr(), annot=True, fmt=”.2f”) plt.title(“Correlation”,fontsize=5) plt.show()
<img src="https://d1jnx9ba8s6j9r.cloudfront.net/blog/wp-content/uploads/2019/07/4-2.png" alt="" /
>
Analysis
After visualization, we can do our analysis by looking at the various graphs and graphs. Suppose we are working on job data, by looking at the visual representation of a particular job in a region we can distinguish the number of jobs in a particular domain.
From the above analysis, we can assume the following results
The number of part-time jobs in
- the dataset is much smaller compared to
- less than 500, full-time jobs are more than 2500
- Based on this analysis, we can build a prediction model.
full-time jobs. While part-time jobs are
.
In this python anaconda
tutorial, we’ve understood how we can set up anaconda for python with use cases that covered python fundamentals, data analytics, and machine learning. With over 300 packages for data science, anaconda provides optimal support with efficient results. To master your python skills, enroll in Edureka’s Python certification course program and begin your apprenticeship.
Don’t miss your chance to become a Python master. Enroll in our comprehensive Master in Python and discover how to write code like a pro.
Do you have any questions? mention them in the comments of this article about ‘Python Anaconda Tutorial’, and we will contact you as soon as possible.