Join my course at Udemy (Python Programming Bible-From beginner to advanced )

Blogger templates

Tuesday 27 September 2022

2. Data Analysis - Pandas Series

 Series Creation

Series creation with default index
  • X= pandas.series([10,20,30,40])  -- by passing a list
  • X.index(), X.values()
  • print(X[0], X[[0,2,3]] , X[1:3] --- Access the series value
Series creation with labeled index
  • X = pd.series([10,20,30,40], Index = ['l1', 'l2', 'l3', 'l4'])
  • X['l1'], X[['l1', 'l2']], X['l2':'l4']
Series creation using dictionary
  • pd.Series(dict1) -- in same order as dictionary
  • pd.Series(dict1, index=['k2', 'k1'])  -- change the order other than what specified in dictionary

Series Filter

  • X(X<0)   -- return all negative element.

Mathematical operation

  • obj + obj2
    • if index is not matching then it will be NAN

check NULL value

  • X.isnull() -- returns boolean array
  • X.notnull() -- returns bollean array

change the index

  • X.index = ['k1', 'k2']
  • X.index.name = "indexName"

Share:

0 comments:

Post a Comment

Feature Top (Full Width)

Pageviews

Search This Blog