I have a data file with thousands of bills. When I try to extract a single cell value I notice the type is <class 'numpy.ndarray'>. Is there a way to extract an element as a primitive value like float or int directly from the dataframe or series?
import pandasql as ps
import pandas as pd
df = pd.read_csv(strFPath, sep='|', encoding='windows-1252')
strQry = "SELECT SUM(BILLHOURS) AS 'BILLHOURS' FROM df"
dfQry = ps.sqldf(strQry, globals())
intHoursAll = float(dfQry.values[0].round(2))
Yes, I think you can use
ilocFor example, to extract the value of the first column in the first row (0,0),
write this.
value = df.iloc[0, 0](value type depends on the data type of the cell. For example, numeric data can be int or float.)
Or
value = df['your_column_name'].iloc[0](df['your_column_name'] return pandas' series with all the values in that column)
Additionally, if you want to return the <class 'numpy.ndarray'> type,
write this.
numpyArrayValues = df['column_name'].values