WillianFuks / tfcausalimpact

Python Causal Impact Implementation Based on Google's R Package. Built using TensorFlow Probability.
Apache License 2.0
593 stars 70 forks source link

AttributeError: 'NoneType' object has no attribute 'loc' #81

Open benji931122 opened 7 months ago

benji931122 commented 7 months ago

I am using the following code and the error persists. The thing is that a week ago the code was working just fine with the exact same Dataframe:

import pandas as pd
from causalimpact import CausalImpact

data = pd.read_csv('https://raw.githubusercontent.com/WillianFuks/tfcausalimpact/master/tests/fixtures/arma_data.csv')[['y', 'X']]
data.iloc[70:, 0] += 5

pre_period = [0, 69]
post_period = [70, 99]

ci = CausalImpact(data, pre_period, post_period)
print(ci.summary())
print(ci.summary(output='report'))
ci.plot()

Pandas version is 2.1.3 and causalimpact version is 0.2.6

WillianFuks commented 7 months ago

Hi @benji931122 ,

tfci does not have version 0.2.6. Apparently in your workflow at some point you are installing another ci package. tfcausalimpact should be present in your pip freeze and no other package with conflicting name should appear as well.

benji931122 commented 7 months ago

Thanks! It does show up only once when I do the pip freeze. What can I do to use this library as intended?

WillianFuks commented 7 months ago

So you'll have to uninstall the current package that you have and install again tfci via pip install -U tfcausalimpact. After that you could run: pip show tfcausalimpact and it should return something like

Name: tfcausalimpact
Version: 0.0.14
Summary: Python version of Google's Causal Impact model on top of Tensorflow Probability.
Home-page: https://github.com/WillianFuks/tfcausalimpact
Author: Willian Fuks
Author-email: willian<dot>fuks<at>gmail.com
License: Apache License 2.0
Location: path/to/package
Requires: jinja2, pandas, tensorflow, tensorflow-probability, matplotlib
Required-by: