Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow_unbalanced_panel = False is not working #24

Open
alexanderquispe opened this issue Jul 27, 2024 · 0 comments
Open

allow_unbalanced_panel = False is not working #24

alexanderquispe opened this issue Jul 27, 2024 · 0 comments

Comments

@alexanderquispe
Copy link
Contributor

from csdid.att_gt import ATTgt 
import pandas as pd 
# Load the CSV file 
file_path = 'C:/Users/Alexander/Documents/GitHub/csdid/data/cohort_2023.csv' 
data = pd.read_csv(file_path)
# Prepare  the data
data['customer_id_numeric'] = data['customer_id'].astype('category').cat.codes 
# Create an instance of the ATTgt class and fit the model 
out = ATTgt(yname="ln_gms",gname="first.treat", idname="customer_id_numeric",        
     tname="time_period", data=data, allow_unbalanced_panel = False).fit(est_method='ipw', bstrap = True) 
# Display the results 
out.summ_attgt().summary2
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
c:\Users\Alexander\anaconda3\envs\tensorflow\lib\site-packages\pandas\core\indexing.py in _validate_tuple_indexer(self, key)
    903             try:
--> 904                 self._validate_key(k, i)
    905             except ValueError as err:

c:\Users\Alexander\anaconda3\envs\tensorflow\lib\site-packages\pandas\core\indexing.py in _validate_key(self, key, axis)
   1517         else:
-> 1518             raise ValueError(f"Can only index by location with a [{self._valid_types}]")
   1519 

ValueError: Can only index by location with a [integer, integer slice (START point is INCLUDED, END point is EXCLUDED), listlike of integers, boolean array]

The above exception was the direct cause of the following exception:

ValueError                                Traceback (most recent call last)
C:\Users\ALEXAN~1\AppData\Local\Temp/ipykernel_24432/3877272001.py in <module>
     10 data['customer_id_numeric'] = data['customer_id'].astype('category').cat.codes
     11 # Create an instance of the ATTgt class and fit the model
---> 12 out = ATTgt(yname="ln_gms",gname="first.treat", idname="customer_id_numeric",        
     13      tname="time_period", data=data, allow_unbalanced_panel = False).fit(est_method='ipw', bstrap = True) 
     14 # Display the results

c:\Users\Alexander\anaconda3\envs\tensorflow\lib\site-packages\csdid\att_gt.py in __init__(self, yname, tname, idname, gname, data, control_group, xformla, panel, allow_unbalanced_panel, clustervar, weights_name, anticipation, cband, biters, alp)
...
--> 906                 raise ValueError(
    907                     "Location based indexing can only have "
    908                     f"[{self._valid_types}] types"

ValueError: Location based indexing can only have [integer, integer slice (START point is INCLUDED, END point is EXCLUDED), listlike of integers, boolean array] types
Output is truncated. View as a [scrollable element](command:cellOutput.enableScrolling?4242d70f-e8c8-4f7f-938c-97ed0d0531c4) or open in a [text editor](command:workbench.action.openLargeOutput?4242d70f-e8c8-4f7f-938c-97ed0d0531c4). Adjust cell output [settings](command:workbench.action.openSettings?%5B%22%40tag%3AnotebookOutputLayout%22%5D)...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant