Hi George,
No, There is no API function to fetch field group id from field group name and you will need to write your own sql query for the purpose.
Also, In your example you have passed the profile_group_id to the bp_get_profile_field_data. Please note, it does not take that as a valid argument. It only accepts user_id and field. group id is not required for fetching field data.
Now, If we forget about the group name API and come to the original requirement, Do you plan to fetch the data for multiple users(In loop) or just once/twice.
For fetching data, these two functions work
You can either use
$data = xprofile_get_field_data( $field, $user_id = 0, $multi_format = 'array' )
where $field is field id or name( If you know the id, It will fetch from any group, Name has the issue)
or as you specified
$data = bp_get_profile_field_data( array(
'user_id' => $user_id,
'field_id' => $field
) );
The xprofile data APIs do not allow passing group in general. You either pass a field id or name.
The problem will happen when multiple fields have same name. In that case, the first field with the name matches if you use the above functions.
Another point, In both the cases, There is no group arguement and if you use field name, that will need one extra query(field id should be preferred if the id is known).
Honestly speaking, It is ok to use it one or 2 time on page but avoid using it inside the loop. If you plan to use it inside the loop, you should try to first fetch the xprofile data and cache and then use any of these functions. One way to cache will be by calling
BP_XProfile_ProfileData::get_value_byid( $field_id, $user_ids )
Where $field_id is the id of field(not name) and $user_ids is one or more user ids.
Hope that helps.