KEMBAR78
Series data structure in Python Pandas.pptx
Pandas
Pandas is an open-source library that uses for working with relational or labeled data both
easily.
It provides various data structures and operations for manipulating numerical data and
time series.
It offers a tool for cleaning and processes your data.
It is the most popular Python library that is used for data analysis.
Handling missing Data
Reading data from files and writing data to files
Benefits of Pandas
The following are the advantages of pandas overusing other languages:
Representation of Data: Through its DataFrame and Series, it presents the data in a
manner that is appropriate for data analysis.
Clear code: Pandas' clear API lets you concentrate on the most important part of the code.
In this way, it gives clear and brief code to the client.
It supports two data structures:
Series
Dataframe
Series
A Pandas Series is like a column in a table.
It is a one-dimensional array holding data of any type.
Pip install pandas
import pandas as pd
a = [1, 3, 8,9,7]
myvar = pd.Series(a)
print(myvar)
Pandas
INDEX
import pandas as pd
a = [1, 3, 2,’AVANTHI”]
myvar = pd.Series(a)
print(myvar[0])
Create Labels
With the index argument, you can name your own labels.
import pandas as pd
a = [2, 8, 2]
myvar = pd.Series(a, index = ["x", "y", "z"])
print(myvar)
#print(myvar["y"])
Key/Value Objects as Series
You can also use a key/value object, like a dictionary, when creating a Series.
import pandas as pd
marks = {"DEP": 80, "DBMS": 81, "ML":90}
myvar = pd.Series(marks)
print(myvar)
Retrieve
To select only some of the items in the dictionary, use the index argument and specify only
the items you want to include in the Series.
import pandas as pd
marks = {"DEP": 80, "DBMS": 81, "ML":90}
myvar = pd.Series(marks, index = ["DEP", "ML"])
print(myvar)
Find datatype and length
import numpy as np
import pandas as pd
a=pd.Series(data=[1,2,3,4])
b=pd.Series(data=[4.9,8.2,5.6],
index=['x','y','z'])
print(a.dtype)
print(a.itemsize)
print(b.dtype)
print(b.itemsize)
map
Pandas Series.map()
The main task of map() is used to map the values from two series that have a common
column.
Syntax:
Series.map(arg, na_action=None)
import pandas as pd
import numpy as np
a=pd.Series(['Java','C','C++',np.nan])
a.map({'Java':'Core'})
s=a.map('I like {}'.format,na_action='ignore')
print(s)
STD()
Pandas Series.std()
The Pandas std() is defined as a function for calculating the standard deviation of the given
set of numbers, DataFrame, column, and rows
import pandas as pd
# calculate standard deviation
import numpy as np
print(np.std([4,7,2,1,6,3]))
print(np.std([6,9,15,2,-17,15,4]))

Series data structure in Python Pandas.pptx

  • 1.
    Pandas Pandas is anopen-source library that uses for working with relational or labeled data both easily. It provides various data structures and operations for manipulating numerical data and time series. It offers a tool for cleaning and processes your data. It is the most popular Python library that is used for data analysis. Handling missing Data Reading data from files and writing data to files
  • 2.
    Benefits of Pandas Thefollowing are the advantages of pandas overusing other languages: Representation of Data: Through its DataFrame and Series, it presents the data in a manner that is appropriate for data analysis. Clear code: Pandas' clear API lets you concentrate on the most important part of the code. In this way, it gives clear and brief code to the client. It supports two data structures: Series Dataframe
  • 3.
    Series A Pandas Seriesis like a column in a table. It is a one-dimensional array holding data of any type. Pip install pandas import pandas as pd a = [1, 3, 8,9,7] myvar = pd.Series(a) print(myvar)
  • 4.
    Pandas INDEX import pandas aspd a = [1, 3, 2,’AVANTHI”] myvar = pd.Series(a) print(myvar[0])
  • 5.
    Create Labels With theindex argument, you can name your own labels. import pandas as pd a = [2, 8, 2] myvar = pd.Series(a, index = ["x", "y", "z"]) print(myvar) #print(myvar["y"])
  • 6.
    Key/Value Objects asSeries You can also use a key/value object, like a dictionary, when creating a Series. import pandas as pd marks = {"DEP": 80, "DBMS": 81, "ML":90} myvar = pd.Series(marks) print(myvar)
  • 7.
    Retrieve To select onlysome of the items in the dictionary, use the index argument and specify only the items you want to include in the Series. import pandas as pd marks = {"DEP": 80, "DBMS": 81, "ML":90} myvar = pd.Series(marks, index = ["DEP", "ML"]) print(myvar)
  • 8.
    Find datatype andlength import numpy as np import pandas as pd a=pd.Series(data=[1,2,3,4]) b=pd.Series(data=[4.9,8.2,5.6], index=['x','y','z']) print(a.dtype) print(a.itemsize) print(b.dtype) print(b.itemsize)
  • 9.
    map Pandas Series.map() The maintask of map() is used to map the values from two series that have a common column. Syntax: Series.map(arg, na_action=None) import pandas as pd import numpy as np a=pd.Series(['Java','C','C++',np.nan]) a.map({'Java':'Core'}) s=a.map('I like {}'.format,na_action='ignore') print(s)
  • 10.
    STD() Pandas Series.std() The Pandasstd() is defined as a function for calculating the standard deviation of the given set of numbers, DataFrame, column, and rows import pandas as pd # calculate standard deviation import numpy as np print(np.std([4,7,2,1,6,3])) print(np.std([6,9,15,2,-17,15,4]))