Python for Data Analytics: A Beginners Guide for Learning Python Data Analytics from A-Z by Root Alex
Author:Root, Alex [Root, Alex]
Language: eng
Format: epub
Published: 2019-09-04T16:00:00+00:00
Important Functionalities
We will see the basic and important mechanisms of data interaction in DataFrame and series in this section. We will not focus on all the documentation present in the pandas library; but instead we will see the most important and frequently used functionalities.
Re-indexing
An important function to perform on pandas objects is to re-index. It is a process in which we create a new object and the data follows to the new index. Let us see an example:
In [ 1 ]: first_obj = Series( [2.4, 5.1, 3.7, 7.6], index = ['v', 'u', 'w', 'x'] )
In [ 2 ]: first_obj
Out [ 2 ]:
v 2.4
u 5.1
w 3.7
x 7.6
Now we will call the reindex function on the first object. It will rearrange all the data as per the new index.
In [ 3 ]: new_obj = obj.reindex( ['u', 'v', 'w', 'x', 'y'] )
In [ 4 ]: new_obj
Out [ 4 ]:
u 5.1
v 2.4
w 3.7
x 7.6
y NaN
We can also set the missing values to 0 if we use the fill_value argument inside the function.
In [ 5 ]: newobj.reindex( ['u', 'v', 'w', 'x', 'y' ], fill_value = 0)
Out[ 5 ]:
u 5.1
v 2.4
w 3.7
x 7.6
y 0.0
We can also use the arguments ffill and bfill to carry values forward or carry values backwards, respectively.
Here are some of the arguments that can be used with the reindex function.
Argument name
Description of the argument
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Computer Vision & Pattern Recognition | Expert Systems |
Intelligence & Semantics | Machine Theory |
Natural Language Processing | Neural Networks |
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8282)
Test-Driven Development with Java by Alan Mellor(6639)
Data Augmentation with Python by Duc Haba(6547)
Principles of Data Fabric by Sonia Mezzetta(6311)
Learn Blender Simulations the Right Way by Stephen Pearson(6197)
Microservices with Spring Boot 3 and Spring Cloud by Magnus Larsson(6067)
Hadoop in Practice by Alex Holmes(5958)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(5802)
RPA Solution Architect's Handbook by Sachin Sahgal(5461)
Big Data Analysis with Python by Ivan Marin(5318)
The Infinite Retina by Robert Scoble Irena Cronin(5160)
Life 3.0: Being Human in the Age of Artificial Intelligence by Tegmark Max(5137)
Pretrain Vision and Large Language Models in Python by Emily Webber(4282)
Infrastructure as Code for Beginners by Russ McKendrick(4043)
Functional Programming in JavaScript by Mantyla Dan(4037)
The Age of Surveillance Capitalism by Shoshana Zuboff(3943)
WordPress Plugin Development Cookbook by Yannick Lefebvre(3754)
Embracing Microservices Design by Ovais Mehboob Ahmed Khan Nabil Siddiqui and Timothy Oleson(3559)
Applied Machine Learning for Healthcare and Life Sciences Using AWS by Ujjwal Ratan(3533)
