0
I have a table 'f0219' with a column 'Value'. Originally, value is like Object. I use the following command to convert it to float.
f0219['Valor'] = pd.to_numeric(f0219['Valor'], errors='coerce')
Note: astype does not work. I think it is because this column has mixed types. Well, after the conversion, when I give a f0219.info(), the types of the two columns of my table appear as following:
CPF 27417 non-null int64
Valor 0 non-null float64
I have a value in the 'Value' column of 4753.20. However, when I try to filter all values with the below command, larger than 1000, the result is returned to me with an error message:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-68-4f8e4c49b332> in <module>
----> 1 f0219[f0219.Valor>2232,00]
/usr/local/lib/python3.6/dist-packages/pandas/core/frame.py in __getitem__(self, key)
2925 if self.columns.nlevels > 1:
2926 return self._getitem_multilevel(key)
-> 2927 indexer = self.columns.get_loc(key)
2928 if is_integer(indexer):
2929 indexer = [indexer]
/usr/local/lib/python3.6/dist-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
2654 'backfill or nearest lookups')
2655 try:
-> 2656 return self._engine.get_loc(key)
2657 except KeyError:
2658 return self._engine.get_loc(self._maybe_cast_indexer(key))
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
TypeError: '(0 False
1 False
2 False
3 False
Do you happen to change
,
for.
resolves?f0219[f0219.Valor>2232.00]
instead off0219[f0219.Valor>2232,00]
.– AlexCiuffa
That’s right. I put '.' in the decimal and reapplied the conversion. It worked. Grateful.
– roger roger