Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Server Side Programming Articles - Page 543 of 2650
255 Views
The apply() method in pandas Series is used to call our function on a series object. By using this apply() method we can apply our own function on our series object.The apply() method is very similar to some other pandas series methods like agg() and map(). Here the difference is we can apply a function on values of the given series object.Example 1# import pandas package import pandas as pd # create a pandas series s = pd.Series([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) print(s) # Applying a function result = s.apply(type) print('Output of apply ... Read More
129 Views
To compute the roots of a Legendre series, use the polynomial.legendre.lagroots() method in Python. The method returns an array of the roots of the series. If all the roots are real, then out is also real, otherwise it is complex. The parameter c is a 1-D array of coefficients.StepsAt first, import the required library −from numpy.polynomial import legendre as LCompute the roots of a Legendre series −j = complex(0, 1) print("Result...", L.legroots((-j, j)))Get the datatype −print("Type...", L.legroots((-j, j)).dtype)Get the shape −print("Shape...", L.legroots((-j, j)).shape)Examplefrom numpy.polynomial import legendre as L # To compute the roots of a Legendre series, use the ... Read More
762 Views
The basic operation of pandas.Series.append() method is used to concatenate a series with another series. And it will return a new series with resultant elements.This append() method has some parameters like to_append, ignore_index, and verify_integrity to concatenate two pandas series objects.Example 1# import the required packages import pandas as pd import numpy as np series1 = pd.Series(np.random.randint(1, 100, 5)) print(series1) series2 = pd.Series(np.random.randint(1, 100, 4)) print(series2) # apply append method on series result = series1.append(series2) print("Resultant series: ", result)ExplanationIn the following example, we have appended a pandas series object “series1” with another series object “series2”. we ... Read More
410 Views
To compute the roots of a Legendre series, use the polynomial.legendre.legroots() method in Python. The method returns an array of the roots of the series. If all the roots are real, then out is also real, otherwise it is complex. The parameter c is a 1-D array of coefficients.StepsAt first, import the required library −from numpy.polynomial import legendre as LTo compute the roots of a Legendre series, use the polynomial.legendre.legroots() method in Python −print("Result...", L.legroots((0, 1, 2)))Get the datatype −print("Type...", L.legroots((0, 1, 2)).dtype)Get the shape −print("Shape...", L.legroots((0, 1, 2)).shape) Examplefrom numpy.polynomial import legendre as L # To compute the ... Read More
198 Views
To generate a Legendre series, use the polynomial.legendre.legfromroots() method in Python. The method returns a 1-D array of coefficients. If all roots are real then out is a real array, if some of the roots are complex, then out is complex even if all the coefficients in the result are real. The parameter roots are the sequence containing the roots.StepsAt first, import the required library −from numpy.polynomial import legendre as LGenerate a Legendre series using the polynomial.legendre.legfromroots() method in Python −j = complex(0, 1) print("Result...", L.legfromroots((-j, j)))Get the datatype −print("Type...", L.legfromroots((-j, j)).dtype)Get the shape −print("Shape...", L.legfromroots((-j, j)).shape)Examplefrom numpy.polynomial import legendre ... Read More
548 Views
The any() is one of the pandas.Series method, which is used to verify if there is any non-zero value present in the given series object.The pandas.Series method “any()” will return a boolean value as an output. It will return True if any value in the given series is non-zero. otherwise, it will return False for all zero values of the given series object.Example 1import pandas as pd # create a series s = pd.Series([False, False]) print(s) print("Output: ") print(s.any())ExplanationLet’s see an example, here we have created a pandas series object with all zero-values (nothing but False). And ... Read More
748 Views
A pandas series object is used to store 1-dimensional labeled data, that data is called values and the labels are called indexes in pandas.In pandas data structures we can store any kind of data like text data, integer values, and time sequence, and more. We can access series elements by using the respected labels. instead of accessing elements by labels, we can get all elements in a ndarray type object.Example1import pandas as pd # creating a series s = pd.Series([10, 10, 20, 30, 40]) print(s) # Getting values values = s.values print('Output: ') # displaying outputs ... Read More
662 Views
The “.loc” is an attribute of the pandas.Series object which is used to access elements from series based on label indexing. And It works similar to pandas.Series “at” attribute but the difference is, the “at” attribute accesses only a single element whereas the “loc” attribute can access a group of elements using labels.The “loc” attribute accesses the labels based on labels and it also supports slicing object with labels.Example 1import pandas as pd import numpy as np # creating pandas Series object series = pd.Series({'B':'black', 'W':'white', 'R':'red', 'Bl':'blue', 'G':'green'}) print(series) print("Output: ") print(series.loc['B'])ExplanationIn this following example, we created ... Read More
477 Views
A Series is a pandas data structure that is used to store the labeled data in a single dimension, the labels can be anything like text data, integer values, and time sequence. by using these labels we can access elements of a given series and we can do data manipulations too.In pandas.Series the labels are called indexes, If you want to get index labels separately then we can use pandas.Series “index” attribute.Example 1import pandas as pd # creating a series s = pd.Series([100, 110, 120, 130, 140]) print(s) # Getting index data index = s.index print('Output: ') ... Read More
582 Views
The pandas.Series.iloc is used to access a group of elements from pandas series object by providing integer-based location index values.The attribute .iloc is taking integer values for accessing a particular series element. Generally, the position-based index values are represented from 0 to length-1. Beyond this range only we can access the series elements otherwise it will raise an “IndexError”. But for slice indexer, it won’t rise “IndexError” for out-of-bound index value, because it allows out-of-bounds indexing.Example 1import pandas as pd import numpy as np # create a sample series s = pd.Series([1, 2, 3, 4, 5, 6, 7, 8, ... Read More