I am getting the following error in my code. confirmed_India, recovered_India, deaths_India are list of table that includes a predefined dataset for corona cases .Code:
confirmed_India_ts = confirmed_df[confirmed_df['Country/Region'] == "India"]
confirmed_India_ts = confirmed_India_ts.drop(
['Lat','Long','Country/Region','Province/State'],axis=1).reset_index(drop=True).sum()
deaths_India_ts = deaths_df[deaths_df['Country/Region'] == "India"]
confirmed_India_ts = deaths_India_ts.drop(
['Lat','Long','Country/Region','Province/State'],axis=1).reset_index(drop=True).sum()
recovered_India_ts = recovered_df[recovered_df['Country/Region'] == "India"]
recovered_India_ts = deaths_India_ts.drop(
['Lat','Long','Country/Region','Province/State'],axis=1).reset_index(drop=True).sum()
active_India_ts = pd.Series(
data = np.array(
[(x1 - x2 - x3) for (x1, x2, x3) in zip(
confirmed_India_ts.values, deaths_India_ts.values,
recovered_India_ts.values)
]
),
index = confirmed_India_ts.index
)
error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-54-68268b5b4ce7> in <module>
14 data = np.array(
15 [(x1 - x2 - x3) for (x1, x2, x3) in zip(
---> 16 confirmed_India_ts.values, deaths_India_ts.values, recovered_India_ts.values)
17 ]
18
<ipython-input-54-68268b5b4ce7> in <listcomp>(.0)
13 active_India_ts = pd.Series(
14 data = np.array(
---> 15 [(x1 - x2 - x3) for (x1, x2, x3) in zip(
16 confirmed_India_ts.values, deaths_India_ts.values, recovered_India_ts.values)
17 ]
TypeError: unsupported operand type(s) for -: 'int' and 'str'
This error is suggesting that you are trying to subtract Integer type and String type. So I suggest you check your Data type of each of your x1,2,3 RIGHT before doing that (x1 - x2 - x3) Operation. Maybe you messed up one of the types during preprocessing. Eg. x1 is Int type, but x2 is a string.
Please provide more info so I maybe able to help you.