Python Pandas Data Structures

Pandas is the most popular Python library that is used for data analysis. It offers a tool for cleaning and processes your data. It is an open-source library.
Pandas, supports two data structures:

Series:

It is 1=D labeled array which is capable of holding any data types  that include integers, strings, float, python object etc. It is homogeneous. It's size is immutable.

DataFrame:

It us a 2-D tabular data structure whose size is mutable. It is heterogeneous in nature. It is a 2-D data structure which is aligned in a tabular from like spreadsheet or SQL table or dict of series object. Pandas DataFrame consists of three principal components, the data, rows, and columns. It is generally the most commonly used pandas object. Like Series, DataFrame also accept many different kinds of input.

Tue, 02/09/2021 - 18:20

Authored by

Devanshi, is working as a Data Scientist with iVagus. She has expertise in Python, NumPy, Pandas and other data science technologies.
Tags

Comments

vodaso , Mon, 08/29/2022 - 20:01

Reverse Linear Search

Description

Given a list of non-negative integers, write a code to search the position of an element in the list in the reverse order. Print 'Key not found', when the element is not present in the given list.

Also, if the key is repeated, print the index where the key is appearing for the first time in reverse order. Assume that the right most element of the list has its index as 0, second last element has its index as 1 and so on.

The code should take :

  • A list as input from the user.
  • The key you are searching for, as an input from the user.

Sample Input:

[6, 8, 3, 5, 9, 1, 2]

9

Sample Output:

2

Here the output is 2 because the position of number 9 is 2 from the reverse order as mentioned in the question.

Sample Input:

[8, 1, 3, 2, 5, 1, 2]

1

Sample Output:

1

The index of the first occurrence of 1 from the right has been printed.

Sample Input:

[8, 1, 3, 2, 5, 1, 2]

9

Sample Output: Key not found