# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# # Tutorial Pandas
#
# ## DataFrame.loc[]
# In order to access a specific data item you have to use DataFrame.loc[(value_index_1, value_index_2, ...)] 
# ```Python
# state.loc[(1)]  # returns a DataFrame containing all data of object id=1
# state.loc[(1), ('ts','x')]  # returns a DataFrame with selected columns of object id=1
# state.loc[(1)].ts.values # returns an array containing the values of column 'ts'
# state.index.get_level_values(0).unique() # lists the available object ids
#
# ```
# ## iterating over all objects
# In order to iterate object-wise over the DataFrame it is preferable to use the groupby function
# ```Python
# # iterates over all objects and prints its corresponding DataFrame with removed column 'oid'
# # on obj_state you can apply again the .loc[] method to access its data
# for oid, obj_state in state.groupby('oid'):
#     display(obj_state)
#     
# ```
# ## index modifications
# ```Python
# DataFrame.reset_index() # flattens the DataFrame and makes previous index columns to regular columns
# DataFrame.set_index(['oid','eid'], inplace=True)  # sets the index in the given order according to the given column names
#
# # In order to keep a good access performance it is preferable to sort the index after index modifications. 
# my_dataframe = my_dataframe.sort_index() 
#     
# ```



StarcoderdataJupyterScriptsDedupFiltered