Warning: opendir(/home/idphekra/public_html/rdatacode.com/wp-content/cache/db/options//d36): failed to open dir: No such file or directory in /home/idphekra/public_html/rdatacode.com/wp-content/plugins/w3-total-cache/Util_File.php on line 158

Warning: Cannot modify header information - headers already sent by (output started at /home/idphekra/public_html/rdatacode.com/wp-content/plugins/w3-total-cache/Util_File.php:158) in /home/idphekra/public_html/rdatacode.com/wp-includes/feed-rss2.php on line 8
series Archives - We provide R, Python, Statistics Online-Learning Course https://rdatacode.com/tag/series/ Online training course for R, Python, Statistics and Data Science Fri, 05 Sep 2025 20:09:46 +0000 en-US hourly 1 https://rdatacode.com/wp-content/uploads/2023/11/cropped-R-logo-1-e1700565850952-32x32.jpg series Archives - We provide R, Python, Statistics Online-Learning Course https://rdatacode.com/tag/series/ 32 32 Mathematical operations between Pandas Series in Python https://rdatacode.com/mathematical-operations-between-pandas-series-in-python/?utm_source=rss&utm_medium=rss&utm_campaign=mathematical-operations-between-pandas-series-in-python https://rdatacode.com/mathematical-operations-between-pandas-series-in-python/#respond Wed, 21 Aug 2024 11:50:51 +0000 https://rdatacode.com/?p=1794 We provide affordable online training course(via ZOOM meeting) for Python and R programming at fundamental level, click here for more details. Series is the simplest data structure from Pandas library in Python. It stores usually labeled data, i.e. a list of values and and a list of labels combined and Read more…

The post Mathematical operations between Pandas Series in Python appeared first on We provide R, Python, Statistics Online-Learning Course.

]]>
We provide affordable online training course(via ZOOM meeting) for Python and R programming at fundamental level, click here for more details.

Series is the simplest data structure from Pandas library in Python. It stores usually labeled data, i.e. a list of values and and a list of labels combined and saved in an individual object. When we perform mathematical operations, such as addition or subtraction between two Series, the operation will be carried out only with those values that have common corresponding labels in both Series. Otherwise, the corresponding value in the resulting Series will be NaN (Not a Number) value(s). In the next example, we show two examples of this mechanism implemented in Python IDE.

#Import Pandas module
import pandas as pd
#create a Series S1, with input from a dictionary
D1 = {'var1':25, 'var2': 32, 'var3': 8, 'var4': 19}
S1 = pd.Series(D1)
S1
#output
var1    25
var2    32
var3     8
var4    19
dtype: int64
#similarly, we create a second Series, having same labels as the first
D2 = {'var1':17, 'var2': 301, 'var3': 16, 'var4': 201}
S2 = pd.Series(D2)
S2
#output
var1     17
var2    301
var3     16
var4    201
dtype: int64
#we perform addition of these two Series
S1 + S2
#result is a Series too, with the values coming from addition 
#of corresponding values in both Series
var1     42
var2    333
var3     24
var4    220
dtype: int64
#Now we create a third Series, with some new labels
D3 = {'var1':11, 'var3': 28, 'var5': 36, 'var6': 9}
S3 = pd.Series(D3)
S3
#output
var1    11
var3    28
var5    36
var6     9
dtype: int64
#then we perform addition between the first and third Series
S1 + S3
#resulting Series have labels that are out-union of these two
#Series' labels, and some values have values NaN, because
#those labels are not found in both inputting Series
var1    36.0
var2     NaN
var3    36.0
var4     NaN
var5     NaN
var6     NaN
dtype: float64

You can also watch videos on our YouTube channel for more understanding of Python programming skills.

The post Mathematical operations between Pandas Series in Python appeared first on We provide R, Python, Statistics Online-Learning Course.

]]>
https://rdatacode.com/mathematical-operations-between-pandas-series-in-python/feed/ 0
How to create a Pandas Series from a Python dictionary https://rdatacode.com/how-to-create-a-pandas-series-from-a-python-dictionary/?utm_source=rss&utm_medium=rss&utm_campaign=how-to-create-a-pandas-series-from-a-python-dictionary https://rdatacode.com/how-to-create-a-pandas-series-from-a-python-dictionary/#respond Tue, 20 Aug 2024 11:09:16 +0000 https://rdatacode.com/?p=1788 We provide affordable online training course(via ZOOM meeting) for Python and R programming at fundamental level, click here for more details. Pandas Series is a type of data object that stores labeled information. A Series can be created from by inputting a Python dictionary, which stores key-value pairs information. The Read more…

The post How to create a Pandas Series from a Python dictionary appeared first on We provide R, Python, Statistics Online-Learning Course.

]]>
We provide affordable online training course(via ZOOM meeting) for Python and R programming at fundamental level, click here for more details.

Pandas Series is a type of data object that stores labeled information. A Series can be created from by inputting a Python dictionary, which stores key-value pairs information. The dictionary’s key then becomes the label of the resulting Series, and value of the dictionary will be the value of the Series. Alternatively, the label of Series can be manually set than using either the default label from Series or from the key information in the dictionary. In such case, if the manually specified label does not match the value part in the dictionary, the resulting Series will have NaN(not a number) value. Next example codes show how to implement these operations in Python IDE.

#Import Pandas module
import pandas as pd
#Create a dictionary
D1 = {'home': 'Molde', 'age': 25, 'gender': 'male', 'color': 'green'}
S1 = pd.Series(D1)
#Create a Series from inputting dictionary
S1
#output
home      Molde
age          25
gender     male
color     green
dtype: object
#Create a list representing labels for Series
L1 = ['home', 'age', 'gender', 'color', 'height']
#Create a Series, by inputting dictionary and label list
S2 = pd.Series(D1, index=L1)
S2
#output, there is a NaN value in the Series
#because the label list and values in dictionary not match
home      Molde
age          25
gender     male
color     green
height      NaN
dtype: object
#We create a new list for labels, but change sequence
L2 = ['color', 'age', 'gender', 'home', 'height']
#then create a Series from inputting dictionary and
#using new label list
S3 = pd.Series(D1, index=L2)
S3
#output, seems sequence of label has no effect, because
#Pandas will find the labels and assign corresponding values
#in the dictioanry to the Series
color     green
age          25
gender     male
home      Molde
height      NaN
dtype: object

You can also watch videos on our YouTube channel for more understanding of Python programming skills.

The post How to create a Pandas Series from a Python dictionary appeared first on We provide R, Python, Statistics Online-Learning Course.

]]>
https://rdatacode.com/how-to-create-a-pandas-series-from-a-python-dictionary/feed/ 0
Handling NaN (not a number) values in Pandas Series using Python https://rdatacode.com/handling-nan-not-a-number-values-of-pandas-series-in-python/?utm_source=rss&utm_medium=rss&utm_campaign=handling-nan-not-a-number-values-of-pandas-series-in-python https://rdatacode.com/handling-nan-not-a-number-values-of-pandas-series-in-python/#respond Mon, 19 Aug 2024 09:57:21 +0000 https://rdatacode.com/?p=1781 We provide affordable online training course(via ZOOM meeting) for Python and R programming at fundamental level, click here for more details. In Python programming, NaN (not a number) values denotes those missing values, and values that not available among various calculations, such as divided by zero or logarithm of a Read more…

The post Handling NaN (not a number) values in Pandas Series using Python appeared first on We provide R, Python, Statistics Online-Learning Course.

]]>
We provide affordable online training course(via ZOOM meeting) for Python and R programming at fundamental level, click here for more details.

In Python programming, NaN (not a number) values denotes those missing values, and values that not available among various calculations, such as divided by zero or logarithm of a negative number. Pandas allows to assign NaN values to Series and Data Frames. Two useful functions isnull() and notnull() will return boolean object such that we can filter original Series based on TRUE or FALSE values. Next we show some examples of how to deal with NaN values in Pandas Series.

#Import Pandas and Numpy modules
import pandas as pd
import numpy as np
#Create a Series, with one NaN value
T = pd.Series([19, 32, 7, np.NaN, 301])
T
#output
0     19.0
1     32.0
2      7.0
3      NaN
4    301.0
dtype: float64
#isnull() to return a boolean Series of same dimension
T.isnull()
#result
0    False
1    False
2    False
3     True
4    False
dtype: bool
#We can use isnull() to filter out NaN values only
T[T.isnull()]
#result is a new Series
3   NaN
dtype: float64
#notnull() returns boolean Series of same dimension
#if the value is not a NaN, then is TRUE, otherwise FALSE
T.notnull()
#result is a boolean Series of same dimension
0     True
1     True
2     True
3    False
4     True
dtype: bool
#notnull() can also be used to filter out values that 
#are not NaN values, result is a Series.
T[T.notnull()]
#Output
0     19.0
1     32.0
2      7.0
4    301.0
dtype: float64

You can also watch videos on our YouTube channel for more understanding of Python programming skills.

The post Handling NaN (not a number) values in Pandas Series using Python appeared first on We provide R, Python, Statistics Online-Learning Course.

]]>
https://rdatacode.com/handling-nan-not-a-number-values-of-pandas-series-in-python/feed/ 0
Working with duplicate values in Pandas Series with Python https://rdatacode.com/working-with-duplicate-values-in-pandas-series-with-python/?utm_source=rss&utm_medium=rss&utm_campaign=working-with-duplicate-values-in-pandas-series-with-python https://rdatacode.com/working-with-duplicate-values-in-pandas-series-with-python/#respond Sun, 18 Aug 2024 11:34:20 +0000 https://rdatacode.com/?p=1777 We provide affordable online training course(via ZOOM meeting) for Python and R programming at fundamental level, click here for more details. When a Pandas Series data object is created in Python, is values can be evaluated with respect to duplicate values. Pandas provides several handy functions dealing with duplicate values Read more…

The post Working with duplicate values in Pandas Series with Python appeared first on We provide R, Python, Statistics Online-Learning Course.

]]>
We provide affordable online training course(via ZOOM meeting) for Python and R programming at fundamental level, click here for more details.

When a Pandas Series data object is created in Python, is values can be evaluated with respect to duplicate values. Pandas provides several handy functions dealing with duplicate values in Series. unique() returns unique values of the object, value_counts() will list frequency of each unique value, and isin() will return a boolean Series in terms of elements of the Sereis can be found in the specified list. Next we will show you how to implement these functions in Python IDE.

#Import Pandas and Numpy module
import pandas as pd
import numpy as np
#create a Series with duplicate values
S1 = pd.Series([32,19,201,7,32,19])
S1
#output
0     32
1     19
2    201
3      7
4     32
5     19
dtype: int64
#return unique values of the Series
S1.unique()
#result is a Numpy array
array([ 32,  19, 201,   7], dtype=int64)
#count frequency of unique values in the Series
S1.value_counts()
#output, result is a new Series
32     2
19     2
201    1
7      1
Name: count, dtype: int64
#check values of Series are in the specified list
S1.isin([32,19])
#result is a Series with boolean values
0     True
1     True
2    False
3    False
4     True
5     True
dtype: bool
#isin() can be used to filter values, and store to a new Series
S1[S1.isin([32,19])]
#result is a new Series, with fewer elements than original one
0    32
1    19
4    32
5    19
dtype: int64

You can also watch videos on our YouTube channel for more understanding of Python programming skills.

The post Working with duplicate values in Pandas Series with Python appeared first on We provide R, Python, Statistics Online-Learning Course.

]]>
https://rdatacode.com/working-with-duplicate-values-in-pandas-series-with-python/feed/ 0
How to filter a Pandas Series in Python https://rdatacode.com/how-to-filter-a-pandas-series-in-python/?utm_source=rss&utm_medium=rss&utm_campaign=how-to-filter-a-pandas-series-in-python https://rdatacode.com/how-to-filter-a-pandas-series-in-python/#respond Sat, 17 Aug 2024 11:22:47 +0000 https://rdatacode.com/?p=1774 We provide affordable online training course(via ZOOM meeting) for Python and R programming at fundamental level, click here for more details. Series is a data structure type that stores one dimensional labeled data in Pandas module in Python. When a Series is created, its value can be filtered using loc() Read more…

The post How to filter a Pandas Series in Python appeared first on We provide R, Python, Statistics Online-Learning Course.

]]>
We provide affordable online training course(via ZOOM meeting) for Python and R programming at fundamental level, click here for more details.

Series is a data structure type that stores one dimensional labeled data in Pandas module in Python. When a Series is created, its value can be filtered using loc() function, and the result can be stored into a new Series. Filtering conditional can be any of combination of conditional statements. isin() function can also be used to match specific values in filtering statement. Next code examples show implementation of these operations in Python IDE.

#Import Pandas and Numpy module
import pandas as pd
import numpy as np
#Create an array of 5 elements
T = np.array([32, 301, 19, 7, 13])
U = pd.Series(T)
U
#output
0     32
1    301
2     19
3      7
4     13
dtype: int32
#filtering value larger than 10 from Series and save to a new Series
R1 = U.loc[lambda x: x > 10]
R1
#output
0     32
1    301
2     19
4     13
dtype: int32
#Filtering values larger than 10 and smaller than 25
#result saved to a new Series
R2 = U.loc[lambda x: (x > 10) & (x < 25)]
R2
#output
2    19
4    13
dtype: int32
#Filtering values smaller than 10 or larger than 25
#and result saved to a new Series
R3=U.loc[lambda x: (x < 10) | (x > 25)]
R3
#output
0     32
1    301
3      7
dtype: int32
#Filtering values if they match any elements in a specified list
#result saved to a new Series
R4 = U[U.isin([32,301,13,100])]
R4
#output
0     32
1    301
4     13
dtype: int32

You can also watch videos on our YouTube channel for more understanding of Python programming skills.

The post How to filter a Pandas Series in Python appeared first on We provide R, Python, Statistics Online-Learning Course.

]]>
https://rdatacode.com/how-to-filter-a-pandas-series-in-python/feed/ 0
How to create Pandas Series from Numpy array in Python https://rdatacode.com/how-to-create-pandas-series-from-numpy-array-in-python/?utm_source=rss&utm_medium=rss&utm_campaign=how-to-create-pandas-series-from-numpy-array-in-python https://rdatacode.com/how-to-create-pandas-series-from-numpy-array-in-python/#respond Thu, 15 Aug 2024 14:02:30 +0000 https://rdatacode.com/?p=1763 We provide affordable online training course(via ZOOM meeting) for Python and R programming at fundamental level, click here for more details. Pandas module in Python provides two data structures, namely Series and Data Frame. While a Data Frame is a tabular dataset has similar mechanism like a spreadsheet, a Series Read more…

The post How to create Pandas Series from Numpy array in Python appeared first on We provide R, Python, Statistics Online-Learning Course.

]]>
We provide affordable online training course(via ZOOM meeting) for Python and R programming at fundamental level, click here for more details.

Pandas module in Python provides two data structures, namely Series and Data Frame. While a Data Frame is a tabular dataset has similar mechanism like a spreadsheet, a Series is just a one-dimensional data object with labels. Creating a Series can come from manually input values, with pd.Series() functio, or by inputting a Numpy array with the same function, because Pandas module builds upon Numpy. Next example shows creating a Series from simple array of 4 elements.

#Import Pandas and Numpy module
import pandas as pd
import numpy as np
#create an array from Numpy
TA = np.array([32, 19, 301, 7])
TA
#output
array([ 32,  19, 301,   7])
#create a Series, by inputting Numpy array
PS = pd.Series(TA)
PS
#output
0     32
1     19
2    301
3      7
dtype: int32

We have seen the process of creating Series from inputting array is quite simple. However, we have to note that both the array and Series point to the same object in Python working session. If we change the value of one of them, the other will change automatically too. Next example shows this mechanism.

#change the value of element of array
TA[3] = 13
TA
#output
array([ 32,  19, 301,  13])
PS
#output, corresponding element in Series changed too
0     32
1     19
2    301
3     13
dtype: int32
#change the value of element in Series
PS[3] = 32
PS
#output
0     32
1     19
2    301
3     32
TA
#output, corresponding value of element in array changed too
array([ 32,  19, 301,  32])

You can also watch videos on our YouTube channel for more understanding of Python programming skills.

The post How to create Pandas Series from Numpy array in Python appeared first on We provide R, Python, Statistics Online-Learning Course.

]]>
https://rdatacode.com/how-to-create-pandas-series-from-numpy-array-in-python/feed/ 0
How to create Pandas data structure Series in Python https://rdatacode.com/how-to-create-pandas-data-structure-series-in-python/?utm_source=rss&utm_medium=rss&utm_campaign=how-to-create-pandas-data-structure-series-in-python https://rdatacode.com/how-to-create-pandas-data-structure-series-in-python/#respond Wed, 14 Aug 2024 18:55:08 +0000 https://rdatacode.com/?p=1755 We provide affordable online training course(via ZOOM meeting) for Python and R programming at fundamental level, click here for more details. Pandas is a library module designed in Python programming. It is specific for data structure with labeled data. Pandas provides two data structure types, Series and Data Frame. Series Read more…

The post How to create Pandas data structure Series in Python appeared first on We provide R, Python, Statistics Online-Learning Course.

]]>
We provide affordable online training course(via ZOOM meeting) for Python and R programming at fundamental level, click here for more details.

Pandas is a library module designed in Python programming. It is specific for data structure with labeled data. Pandas provides two data structure types, Series and Data Frame. Series is a one-dimensional labeled data, and Data Frame is used for tabular data storage.

Series stores data values and their corresponding labels in two arrays: its value part and index part. To create a Series, function Series() from Pandas can be just applied. Following example show how to create a Series.


#import module Numpy and Pandas 
import pandas as pd
import numpy as np
#create a Series, T, with input an array of 4 elements
T = pd.Series([32, 28, 19, 301])
T
#output
Out[139]: 
0     32
1     28
2     19
3    301
dtype: int64

We can see that Pandas assign index from 0 by default to the Series. Next example shows creating a Series with manually assigning its index.

#create a Series, manually assigning its index
P = pd.Series([32, 28, 19, 301], index=['l', 'm', 'n', 'o'])
P
#output
Out[140]: 
l     32
m     28
n     19
o    301
dtype: int64
#Series's values part
P.values
#output
array([ 32,  28,  19, 301], dtype=int64)
#Series's index part
P.index
#output
Index(['l', 'm', 'n', 'o'], dtype='object')

A Series’s internal elements can be returned with square brackets and the corresponding index.

#value of Series, associated with third index
P[2]
#output
19
#element of Series, associated with index 'o'
P['o']
#output
301
#elements of Series, associated with first to third indices 
P[0:3]
#output, is another Series
l    32
m    28
n    19
dtype: int64
#elements of Series, associated with indices 'm' and 'o' 
P[['m','o']]
#output, is another Series
m     28
o    301
dtype: int64

You can also watch videos on our YouTube channel for more understanding of Python programming skills.

The post How to create Pandas data structure Series in Python appeared first on We provide R, Python, Statistics Online-Learning Course.

]]>
https://rdatacode.com/how-to-create-pandas-data-structure-series-in-python/feed/ 0