I would like to know how to set the field type of ['denominator'] in a geodataframe manually in this expression to "String":

geo_df['denominator'] = df[["basalareap","basalareas","basalaread"]].sum(axis=1)

Where the fields "basalareap","basalareas","basalaread" contain floating point numbers

Automatic it assign the data-type "Double" (when check in QGIS), I tried to add the datatype in the first bracket, geo_df['denominator', type= "String"] but this throws an error.

I'm using Windows 10, Python 3.7

1 Answer 1


Not really GIS related, but you can use the astype method:

geo_df['denominator'] = df[["basalareap","basalareas","basalaread"]].sum(axis=1).astype(str)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.