<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Example Usage for Series
Step1:  Initialize
Step2:  Print
Step3:  Setters and Getters
Step4:  Select Index
Step5:  Set Values
Step6:  Get Values
Step7:  Set and Get by Location
Locations are the index of the index, in other words the index locations from 0...len(index)
Step8:  Head and Tail
Step9:  Delete rows
Step10:  Convert
Step11:  Sort by Index
Step12:  Math Methods
Step13:  Multi-Index
Raccoon does not have true hierarchical mulit-index capabilities like Pandas, but attempts to mimic some of the capabilities with the use of tuples as the index. Raccoon does not provide any checking to make sure the indexes are all the same length or
any other integrity checking.
Step14:  The select_index method works with tuples by allowing the * to act as a wild card for matching.
Step15:  Reset Index
Step16:  Sorted Series
Series will be set to sorted by default if no index is given at initialization. If an index is given at initialization then the parameter sorted must be set to True
Step17:  When sorted=True on initialization the data will be sorted by index to start
<ASSISTANT_TASK:>
Python Code:
# remove comment to use latest development version
import sys; sys.path.insert(0, '../')
# import libraries
import raccoon as rc
Explanation: Example Usage for Series
End of explanation
# empty DataFrame
srs = rc.Series()
srs
# with indexes but no data
srs = rc.Series(index=[1, 2, 3])
srs
# with data
srs = rc.Series(data=[4, 5, 6], index=[10, 11, 12])
srs
Explanation: Initialize
End of explanation
srs.print()
print(srs)
Explanation: Print
End of explanation
# data_name
srs.data_name
srs.data_name = 'new_data'
print(srs)
# index
srs.index
#indexes can be any non-repeating unique values
srs.index = ['apple', 'pear', 7.7]
srs.print()
srs.index = [10, 11, 12]
print(srs)
# the index can also have a name, befault it is "index"
srs.index_name
srs.index_name = 'units'
srs.index_name
# data is a shallow copy, be careful on how this is used
srs.index_name = 'index'
srs.data
Explanation: Setters and Getters
End of explanation
srs.select_index(11)
Explanation: Select Index
End of explanation
# set a single cell
srs.set(10, 100)
print(srs)
# set a value outside current range creates a new row. Can also use [] for setting
srs[13] = 9
srs.print()
# set a subset of rows
srs[[10, 12]] = 66
print(srs)
# using boolean list
srs.set([True, False, True, False], [88, 99])
print(srs)
# setting with slices
srs[12:13] = 33
print(srs)
srs[10:12] = [1, 2, 3]
print(srs)
# set a location
srs.set_location(1, 22)
print(srs)
# set multiple locations
srs.set_locations([0, 2], [11, 27])
print(srs)
# append a row, DANGEROUS as there is not validation checking, but can be used for speed
srs.append_row(14, 99)
print(srs)
# append multiple rows, again no sort check
srs.append_rows([15, 16], [100, 110])
print(srs)
Explanation: Set Values
End of explanation
# get a single cell
srs[10]
# get subset of the index
srs[[11, 12, 13]].print()
# get using slices
srs[11:13].print()
# return as a list
srs.get([11, 12, 13], as_list=True)
Explanation: Get Values
End of explanation
print(srs.get_location(2))
srs.get_location(-1)
srs.get_locations(locations=[0, 2]).print()
srs.get_locations(locations=[0, 2], as_list=True)
srs.set_locations([-1, -2], values=[10, 9])
print(srs)
Explanation: Set and Get by Location
Locations are the index of the index, in other words the index locations from 0...len(index)
End of explanation
srs.head(2).print()
srs.tail(2).print()
Explanation: Head and Tail
End of explanation
srs.delete([10, 13])
print(srs)
Explanation: Delete rows
End of explanation
# return a dict
srs.to_dict()
# exclude the index
srs.to_dict(index=False)
# return an OrderedDict()
srs.to_dict(ordered=True)
Explanation: Convert
End of explanation
srs = rc.Series([6, 7, 8, 9], index=[25, 24, 23, 22])
print(srs)
# sort by index. Sorts are inplace
srs.sort_index()
print(srs)
Explanation: Sort by Index
End of explanation
srs = rc.Series([1, 2, 3])
# test for equality
srs.equality(value=3)
# all math methods can operate on a subset of the index
srs.equality(indexes=[1, 2], value=2)
Explanation: Math Methods
End of explanation
tuples = [('a', 1, 3), ('a', 1, 4), ('a', 2, 3), ('b', 1, 4), ('b', 2, 1), ('b', 3, 3)]
srs = rc.Series([1, 2, 3, 4, 5, 6], index=tuples)
print(srs)
Explanation: Multi-Index
Raccoon does not have true hierarchical mulit-index capabilities like Pandas, but attempts to mimic some of the capabilities with the use of tuples as the index. Raccoon does not provide any checking to make sure the indexes are all the same length or
any other integrity checking.
End of explanation
compare = ('a', None, None)
srs.select_index(compare)
compare = ('a', None, 3)
srs.select_index(compare, 'boolean')
compare = (None, 2, None)
srs.select_index(compare, 'value')
compare = (None, None, 3)
srs.select_index(compare, 'value')
compare = (None, None, None)
srs.select_index(compare)
Explanation: The select_index method works with tuples by allowing the * to act as a wild card for matching.
End of explanation
srs = rc.Series([1, 2, 3], index=[9, 10, 11])
print(srs)
srs.reset_index()
srs
srs = rc.Series([1, 2, 3], index=[9, 10, 11], index_name='new name')
print(srs)
srs.reset_index()
print(srs)
Explanation: Reset Index
End of explanation
srs = rc.Series([3, 5, 4], index=[12, 15, 14], sort=True)
Explanation: Sorted Series
Series will be set to sorted by default if no index is given at initialization. If an index is given at initialization then the parameter sorted must be set to True
End of explanation
srs.print()
srs[16] = 9
print(srs)
srs.set(indexes=13, values=3.5)
print(srs)
Explanation: When sorted=True on initialization the data will be sorted by index to start
End of explanation
<END_TASK>