Home
/
Blog
/
Tech Tutorials
/
How can R Users Learn Python for Data Science ?

How can R Users Learn Python for Data Science ?

Author
Manish Saraswat
Calendar Icon
January 12, 2017
Timer Icon
3 min read
Share

Explore this post with:

Introduction

The best way to learn a new skill is by doing it!

This article is meant to help R users enhance their set of skills and learn Python for data science (from scratch). After all, R and Python are the most important programming languages a data scientist must know.

Python is a supremely powerful and a multi-purpose programming language. It has grown phenomenally in the last few years. It is used for web development, game development, and now data analysis / machine learning. Data analysis and machine learning is a relatively new branch in python.

For a beginner in data science, learning python for data analysis can be really painful. Why?

You try Googling "learn python," and you'll get tons of tutorials only meant for learning python for web development. How can you find a way then?

In this tutorial, we'll be exploring the basics of python for performing data manipulation tasks. Alongside, we'll also look how you do it in R. This parallel comparison will help you relate the set of tasks you do in R to how you do it in python! And in the end, we'll take up a data set and practice our newly acquired python skills.

Note: This article is best suited for people who have a basic knowledge of R language.

Machine learning challenge, ML challenge

Table of Contents

  1. Why learn Python (even if you already know R)
  2. Understanding Data Types and Structures in Python vs. R
  3. Writing Code in Python vs. R
  4. Practicing Python on a Data Set

Why learn Python (even if you already know R)

No doubt, R is tremendously great at what it does. In fact, it was originally designed for doing statistical computing and manipulations. Its incredible community support allows a beginner to learn R quickly.

But, python is catching up fast. Established companies and startups have embraced python at a much larger scale compared to R.

r machine learning vs python machine learning

According to indeed.com (from Jan 2016 to November 2016), the number of job postings seeking "machine learning python" increased much faster (approx. 123%) than "machine learning in R" jobs. Do you know why? It is because

  1. Python supports the entire spectrum of machine learning in a much better way.
  2. Python not only supports model building but also supports model deployment.
  3. The support of various powerful deep learning libraries such as keras, convnet, theano, and tensorflow is more for python than R.
  4. You don't need to juggle between several packages to locate a function in python unlike you do in R. Python has relatively fewer libraries, with each having all the functions a data scientist would need.

Understanding Data Types and Structures in Python vs. R

These programming languages understand the complexity of a data set based on its variables and data types. Yes! Let's say you have a data set with one million rows and 50 columns. How would these programming languages understand the data?

Basically, both R and Python have pre-defined data types. The dependent and independent variables get classified among these data types. And, based on the data type, the interpreter allots memory for use. Python supports the following data types:

  1. Numbers – It stores numeric values. These numeric values can be stored in 4 types: integer, long, float, and complex.
    • Integer – Whole numbers such as 10, 13, 91, 102. Same as R's integer type.
    • Long – Long integers in octa and hexadecimal. R uses bit64 package for hexadecimal.
    • Float – Decimal values like 1.23, 9.89. Equivalent to R's numeric type.
    • Complex – Numbers like 2 + 3i, 5i. Rarely used in data analysis.
  2. Boolean – Stores two values (True and False). R uses factor or character. Case-sensitive difference exists: R uses TRUE/FALSE; Python uses True/False.
  3. Strings – Stores text like "elephant", "lotus". Same as R's character type.
  4. Lists – Like R’s list, stores multiple data types in one structure.
  5. Tuples – Similar to immutable vectors in R (though R has no direct equivalent).
  6. Dictionary – Key-value pair structure. Think of keys as column names, values as data entries.

Since R is a statistical computing language, all the functions to manipulate data and reading variables are available inherently. On the other hand, python hails all the data analysis / manipulation / visualization functions from external libraries. Python has several libraries for data manipulation and machine learning. The most important ones are:

  1. Numpy – Used for numerical computing. Offers math functions and array support. Similar to R’s list or array.
  2. Scipy – Scientific computing in python.
  3. Matplotlib – For data visualization. R uses ggplot2.
  4. Pandas – Main tool for data manipulation. R uses dplyr, data.table.
  5. Scikit Learn – Core library for machine learning algorithms in python.

In a way, python for a data scientist is largely about mastering the libraries stated above. However, there are many more advanced libraries which people have started using. Therefore, for practical purposes you should remember the following things:

  1. Array – Similar to R's list, supports multidimensional data with coercion effect when data types differ.
  2. List – Equivalent to R’s list.
  3. Data Frame – Two-dimensional structure composed of lists. R uses data.frame; python uses DataFrame from pandas.
  4. Matrix – Multidimensional structure of same class data. In R: matrix(); in python: numpy.column_stack().

Until here, I hope you've understood the basics of data types and data structures in R and Python. Now, let's start working with them!

Writing Code in Python vs. R

Let's use the knowledge gained in the previous section and understand its practical implications. But before that, you should install python using Anaconda's Jupyter Notebook. You can download here. Also, you can download other python IDEs. I hope you already have R Studio installed.

1. Creating Lists

In R:

my_list <- list('monday','specter',24,TRUE)
typeof(my_list)
[1] "list"

In Python:

my_list = ['monday','specter',24,True]
type(my_list)
list

Using pandas Series:

import pandas as pd
pd_list = pd.Series(my_list)
pd_list
0     monday
1    specter
2         24
3       True
dtype: object

Python uses zero-based indexing; R uses one-based indexing.

2. Matrix

In R:

my_mat <- matrix(1:10, nrow = 5)
my_mat
     [,1] [,2]
[1,]    1    6
[2,]    2    7
[3,]    3    8
[4,]    4    9
[5,]    5   10

# Select first row
my_mat[1,]

# Select second column
my_mat[,2]

In Python (using NumPy):

import numpy as np
a = np.array(range(10,15))
b = np.array(range(20,25))
c = np.array(range(30,35))
my_mat = np.column_stack([a, b, c])

# Select first row
my_mat[0,]

# Select second column
my_mat[:,1]

3. Data Frames

In R:

data_set <- data.frame(Name = c("Sam","Paul","Tracy","Peter"),
                       Hair_Colour = c("Brown","White","Black","Black"),
                       Score = c(45,89,34,39))

In Python:

data_set = pd.DataFrame({'Name': ["Sam","Paul","Tracy","Peter"],
                         'Hair_Colour': ["Brown","White","Black","Black"],
                         'Score': [45,89,34,39]})

Selecting columns:

In R:

data_set$Name
data_set[["Name"]]
data_set[1]

data_set[c('Name','Hair_Colour')]
data_set[,c('Name','Hair_Colour')]

In Python:

data_set['Name']
data_set.Name
data_set[['Name','Hair_Colour']]
data_set.loc[:,['Name','Hair_Colour']]

Practicing Python on a Data Set

import numpy as np
import pandas as pd
from sklearn.datasets import load_boston

boston = load_boston()

boston.keys()
['data', 'feature_names', 'DESCR', 'target']

print(boston['feature_names'])
['CRIM' 'ZN' 'INDUS' 'CHAS' 'NOX' 'RM' 'AGE' 'DIS' 'RAD' 'TAX' 'PTRATIO' 'B' 'LSTAT']

print(boston['DESCR'])
bos_data = pd.DataFrame(boston['data'])
bos_data.head()

bos_data.columns = boston['feature_names']
bos_data.head()

bos_data.describe()

# First 10 rows
bos_data.iloc[:10]

# First 5 columns
bos_data.loc[:, 'CRIM':'NOX']
bos_data.iloc[:, :5]

# Filter rows
bos_data.query("CRIM > 0.05 & CHAS == 0")

# Sample
bos_data.sample(n=10)

# Sort
bos_data.sort_values(['CRIM']).head()
bos_data.sort_values(['CRIM'], ascending=False).head()

# Rename column
bos_data.rename(columns={'CRIM': 'CRIM_NEW'})

# Column means
bos_data[['ZN','RM']].mean()

# Transform numeric to categorical
bos_data['ZN_Cat'] = pd.cut(bos_data['ZN'], bins=5, labels=['a','b','c','d','e'])

# Grouped sum
bos_data.groupby('ZN_Cat')['AGE'].sum()

# Pivot table
bos_data['NEW_AGE'] = pd.cut(bos_data['AGE'], bins=3, labels=['Young','Old','Very_Old'])
bos_data.pivot_table(values='DIS', index='ZN_Cat', columns='NEW_AGE', aggfunc='mean')

Summary

While coding in python, I realized that there is not much difference in the amount of code you write here; although some functions are shorter in R than in Python. However, R has really awesome packages which handle big data quite conveniently. Do let me know if you wish to learn about them!

Overall, learning both the languages would give you enough confidence to handle any type of data set. In fact, the best part about learning python is its comprehensive documentation available on numpy, pandas, and scikit learn libraries, which are sufficient enough to help you overcome all initial obstacles.

In this article, we just touched the basics of python. There's a long way to go. Next week, we'll learn about data manipulation in python in detail. After that, we'll look into data visualization, and the powerful machine learning library in python.

Do share your experience, suggestions, and questions below while practicing this tutorial!

Subscribe to The HackerEarth Blog

Get expert tips, hacks, and how-tos from the world of tech recruiting to stay on top of your hiring!

Author
Manish Saraswat
Calendar Icon
January 12, 2017
Timer Icon
3 min read
Share

Hire top tech talent with our recruitment platform

Access Free Demo
Related reads

Discover more articles

Gain insights to optimize your developer recruitment process.

Introducing HackerEarth OnScreen: AI-powered interviews, around the clock

Introducing HackerEarth OnScreen: AI-powered interviews, around the clock

Tech hiring has a blind spot, and it's not the resume pile, the take-home tests, or even the interview itself. It's the gap between when a great candidate applies and when your team is available to talk to them. That gap costs you more top talent than any competitor does.

Today, HackerEarth OnScreen closes it permanently.

The real cost of scheduling friction

Most companies assume they lose candidates to better offers. The data tells a different story.

A developer weighing two opportunities almost always moves forward with the company that responded first, not the one that sent a calendar invite for Thursday. AI-generated resumes have flooded inboxes, making screening harder. Engineering teams the people best positioned to evaluate technical depth have limited hours. Recruiters are under pressure to move faster while maintaining quality.

Something had to change.

What OnScreen does

OnScreen doesn't just automate scheduling. It conducts the interview.

A candidate who applies at 11 PM gets a full interview before Monday morning through lifelike AI avatars with built-in identity verification and proctoring. The experience is a genuine two-way conversation: dynamic, adaptive, and role-calibrated. This is not a chatbot filling out a scorecard.

One enterprise customer screened more than 2,000 candidates in a single weekend with complete consistency and zero interviewer bias.

"Recruiters are under pressure more than ever. The volume of applicants has surged, AI-generated resumes have made initial screening harder, and the risk of missing the right candidate keeps climbing. OnScreen was built so that no qualified candidate is overlooked because nobody was available to interview them."
— Vikas Aditya, CEO, HackerEarth

Three capabilities, combined for the first time

In-depth interviewing that evaluates reasoning, not recall.
OnScreen conducts dynamic technical conversations that adapt to how each candidate responds. It probes the depth of knowledge, follows threads, and evaluates the quality of thinking behind each answer not just whether the answer is correct. Every interview runs on a deterministic framework: the same structure for every candidate and no panel-to-panel variation.

Integrated proctoring, built in from the start:
Enterprise-grade proctoring is woven directly into the interview flow not bolted on as an afterthought. Legitimate candidates won't notice it. The ones who shouldn't be in your pipeline will.

KYC-grade candidate verification
OnScreen brings identity verification standards from financial services into technical hiring. Proxy candidates, resume misrepresentation, and skills that don't match the application – all three gaps were closed at the source.

What hiring teams are saying

"Before OnScreen, we had no reliable way to measure candidate quality, especially with the rise of AI-generated CVs. Now, screening is far more objective. Roles that previously took much longer are now being closed within three to four weeks."
— Pawan Kuldip, Head of Human Resources, Discover Dollar Inc.

Built for everyone in the process

For engineering teams:
Fewer hours on screening calls. Senior engineers focus on final-round conversations, not first-pass filters.

For recruiters:
Pipelines that move. Candidates evaluated and scored before the week starts.

For candidates:
A consistent, skills-first experience, regardless of when they apply or where they're located.

OnScreen integrates directly into HackerEarth's existing platform alongside Hiring Challenges, Technical Assessments, and FaceCode. It extends your interviewing capacity without adding headcount.

The hiring bar just got higher. Everywhere.

Top talent expects swift, fair processes. Companies that deliver both, at scale, around the clock, will hire the engineers everyone else is still scheduling calls about.

OnScreen is now live for enterprise customers. Request access at hackerearth.com/ai/onscreen.

HackerEarth powers technical hiring at Google, Amazon, Microsoft, and 500+ global enterprises. The platform supports 10M+ developers across 1,000+ skills and 40+ programming languages.

What It Takes to Keep Gen Z Engaged and Growing at Work

What It Takes to Keep Gen Z Engaged and Growing at Work

Engaging Gen Z employees is no longer an HR checkbox. It's a competitive advantage.

Companies that get this right aren’t just filling roles. They’re building future-ready teams, deepening loyalty, and winning the talent market before competitors even realize they’re losing it.

Why Gen Z is Rewriting the Rules

Gen Z didn’t just enter the workforce. They arrived with a different operating system.

  • They’ve grown up with instant access, real-time feedback, and limitless choice. When work feels slow, rigid, or disconnected, they don’t wait it out. They move on. Retention becomes a live problem, not a future one.
  • They expect technology to be intuitive and fast, communication to be direct and low-friction, and their employer to reflect values in daily action, not just annual reports.

The consequence: Outdated systems and poor employee experiences don’t just frustrate Gen Z. They accelerate attrition.

Millennials vs Gen Z: Similar Generation, Different Expectations

These two cohorts are often grouped together. They shouldn’t be.

The distinction matters because solutions designed for Millennials often fall flat for Gen Z. Understanding who you’re designing for is where effective engagement strategy begins.

Gen Z’s Relationship with Loyalty

Loyalty, for Gen Z, is earned, not assumed.

  • They challenge outdated processes and push for tech-enabled workflows.
  • They constantly evaluate whether their current role offers the growth, flexibility, and purpose they need. If it doesn’t, they start looking elsewhere.

Key insight: This isn’t disloyalty. It’s clarity about what they want. Organizations that align experiences with these expectations gain a competitive edge.

  • High turnover is the cost of ignoring this.
  • Stronger teams are the reward for getting it right.

What Actually Works

1. Rethink Workplace Technology

  • Outdated tools may be invisible to older employees, but Gen Z sees them immediately.
  • Modern HR tech and collaboration platforms improve efficiency and signal investment in people.
  • Invest in tools that reduce friction and enhance daily experience, not just track performance.

2. Flexibility with Clear Accountability

  • Gen Z values autonomy, but also needs clarity to thrive.
  • Hybrid and remote models work when paired with well-defined goals and explicit ownership.
  • Focus on outcomes, not hours. Autonomy with accountability is a combination Gen Z respects.

3. Continuous Feedback, Not Annual Reviews

  • Annual performance reviews feel outdated. Gen Z expects real-time feedback loops.
  • Frequent, actionable feedback helps employees improve faster and signals that their growth matters.
  • Make feedback a weekly habit, not a twice-yearly event.

4. Make Growth Visible

  • If career paths aren’t clear, Gen Z won’t wait. They’ll look elsewhere.
  • Internal mobility, structured learning paths, and reskilling opportunities signal future potential.
  • Invest in learning and development and make career trajectories explicit.

5. Build Real Belonging

  • Inclusion must show up in daily interactions, not just company values documents.
  • Inclusive environments where diverse perspectives are genuinely sought produce better decisions and stronger engagement.
  • Gen Z quickly notices when DEI is performative. Build it into everyday interactions.

6. Connect Work to Purpose

  • Gen Z wants to see how their work matters in a direct, traceable way.
  • Linking individual roles to tangible business outcomes increases ownership and engagement.
  • Purpose-driven work isn’t a perk. It’s a retention strategy.

7. Prioritize Well-Being

  • Burnout is a performance problem before it becomes attrition.
  • Mental health support, sustainable workloads, and genuine flexibility reduce stress and sustain engagement.
  • Policies must be real in practice. Gaps erode trust.

How to Attract Gen Z from the Start

Job Descriptions That Tell the Truth

  • Generic postings don’t convert Gen Z candidates. They want specifics: remote or hybrid expectations, real growth opportunities, and culture in practice.
  • Transparent job descriptions attract better-fit candidates and reduce early attrition.

Skills Over Experience

  • Gen Z and organizations hiring them increasingly value potential over tenure.
  • Skills-based hiring opens access to a broader, more diverse talent pool and builds teams equipped for change.
  • Hire for capability and future-readiness, not just years on a resume.

The Bottom Line

Retaining Gen Z isn’t about perks. It’s about rethinking the employee experience from the ground up.

  • Flexibility without accountability fails.
  • Purpose without visibility is hollow.
  • Growth that isn’t visible or structured drives attrition faster than most organizations realize.

The payoff: When organizations combine the right technology, real flexibility, continuous feedback, visible growth paths, and genuine inclusion:

  • Gen Z doesn’t just stay. They perform at a higher level.
  • Adaptive, future-forward thinking compounds over time.

That’s what separates organizations that thrive in today’s talent market from those constantly replacing people who left for somewhere better.

AI Tools for HR Managers in 2026: What's Actually Working (And What Isn't)

The current state of AI adoption in HR
88% of HR leaders say their organizations have not yet realized significant business value from AI. That number is striking, given that 91% of CHROs now rank AI as their single top priority. The gap is not a technology problem it is an adoption and strategy problem. Most HR teams have added AI to their workflows in some form, but very few have moved past experimentation into real, measurable impact.

This guide is for HR managers who want to change that. Not a list of tools to bookmark and forget, but a clear-eyed look at where AI is delivering results in 2026, what separates the tools that work from the ones that don't, and how to actually use them.

The adoption gap that most HR leaders aren't talking about

AI is present but underutilized.
According to the SHRM State of AI in HR 2026 report, 62% of organizations use AI somewhere in their business. But only 11% have embedded AI into daily workflows, defined as more than 60% of employees using it daily. That is a significant divide and explains why so many AI investments feel underwhelming.

Managers experiment more than employees.
A July 2025 Gartner survey of 2,986 employees found that 46% of managers are experimenting with AI, compared to just 26% of employees. Most organizations encourage exploration but fail to provide the structure, expectations, or training needed to make AI stick. Only 7% of organizations give employees guidance on how to use the time AI saves them.

The result: wasted potential.
Workforces have access to powerful tools but no framework for using them strategically. AI becomes another tab open in the browser, rather than a fundamental shift in how work gets done.

The opportunity is real.
Organizations that have moved from experimentation to integration are seeing tangible outcomes:

  • AI-powered recruitment tools reduce time-to-hire by an average of 30 days.
  • AI automates up to 60% of routine HR tasks, saving employees five or more hours per week.
  • Predictive analytics reduces voluntary turnover by 22–28% in the first year of deployment.

Capturing this opportunity requires the right tools and the right strategy.

Why 2026 is different from every other year of "AI in HR"

1. Skills-based hiring has gone mainstream.
Josh Bersin's 2026 Talent Report found that 72% of companies are moving away from degree requirements in favor of skills-based evaluation. Gartner reports that 65% of enterprises are actively prioritizing it. The traditional resume is no longer the most reliable signal of candidate quality, especially in tech roles where the half-life of skills is just two years.

2. Agentic AI has arrived.
Earlier generations of HR AI could automate tasks or analyze data. Agentic AI can plan, act, and iterate across entire workflows without constant human direction. 48% of large companies have already adopted agentic AI in HR, with projections showing 327% growth by 2027. This is no longer experimental.

3. Regulatory pressure is real.
The EU AI Act now classifies hiring AI as high-risk, making transparency and audit trails a legal requirement. Any AI tool influencing hiring decisions must be explainable. Black-box systems are a compliance liability.

What separates genuinely useful HR AI tools from the rest

They augment judgment rather than replace it.
Great HR AI tools make professionals better at their jobs. They surface the right information at the right moment, flag unnoticed patterns, and reduce cognitive load. Tools that try to remove humans entirely create legal risk and distrust. 88% of HR leaders haven’t seen ROI largely because their tools automate the wrong things.

They generate actionable insight, not just output.
Predictive models identify at-risk employees six months before they leave, skills-gap analyses shape hiring plans before a role opens, and candidate matching highlights transferable potential. This is the difference between AI that saves time and AI that changes decisions.

They are transparent and explainable.
Employees trust AI-generated reviews twice as often when they understand the criteria. 67% of candidates accept AI screening as long as a human makes the final call and the process is explained. Transparency builds trust, drives adoption, and ensures compliance.

Top AI tools for HR managers in 2026

HireVue
Standard for AI-powered video interviews and structured candidate assessments at scale. Cuts time-to-hire by 50%, supports 40+ languages, and uses IO psychologist-vetted guides. Bias audits and deterministic algorithms ensure fairness. Ideal for regulated industries and high-volume hiring.

Eightfold AI
Built for skills-first talent strategy. Maps 1.6 billion career profiles to a skills graph, matching candidates on potential rather than keywords. Increases recruiter productivity by 50%+ and reduces diversity sourcing time by 85%. Best for large enterprises focused on internal mobility and workforce planning.

Workday
Comprehensive HR platform with agentic AI for workforce planning, analytics, and employee lifecycle management. Acquisition of HiredScore integrates AI recruiting orchestration. Suitable for organizations needing a single system for headcount planning to performance reviews.

Lattice
Focuses on employee performance and engagement. AI identifies growth patterns, surfaces feedback trends, and flags disengagement early. Predictive models detect at-risk employees six months in advance, enabling targeted retention strategies. Ideal for culture and retention-focused organizations.

HackerEarth
Covers full tech hiring lifecycle, from sourcing developers through hackathons to live technical interviews. OnScreen AI interview agent uses lifelike avatars for structured, bias-free interviews. Ensures verification and cheat-proof processes. Trusted by Google, Amazon, Microsoft, Barclays, and Walmart.

Moving from experimentation to impact: a practical framework

1. Start with one high-friction problem.
Automate workflows that cost the most time or cause the most inconsistency typically initial candidate screening. Measure outcomes to justify next investments.

2. Define success before deployment.
47% of CHROs haven’t established clear AI productivity metrics. Set baseline and target improvements: time-to-shortlist, quality-of-hire, recruiter hours per hire anything trackable.

3. Put managers in the loop.
AI adoption gaps are often a manager problem. Give managers specific use cases, integrate AI into workflows, and provide language to discuss it with their teams.

The bottom line

AI will not change HR’s fundamental nature it remains a people function requiring judgment, empathy, and context. What AI improves is:

  • The quality of information available for every decision.
  • The time HR teams spend on work that doesn’t require judgment.

Organizations getting ahead in 2026 are those that select the right tools for the right problems and give teams structure to use them effectively. That is where the real advantage lies.

Top Products

Explore HackerEarth’s top products for Hiring & Innovation

Discover powerful tools designed to streamline hiring, assess talent efficiently, and run seamless hackathons. Explore HackerEarth’s top products that help businesses innovate and grow.
Frame
Hackathons
Engage global developers through innovation
Arrow
Frame 2
Assessments
AI-driven advanced coding assessments
Arrow
Frame 3
FaceCode
Real-time code editor for effective coding interviews
Arrow
Frame 4
L & D
Tailored learning paths for continuous assessments
Arrow
Get A Free Demo