I know there is web3.fromWei('myamount','ether') to convert from Wei to Ether.
But what if I have only the Gwei amount?
You can do:
from decimal import Decimal
def covert(amount):
#: Convert gwei to wei
wei_amount = Decimal(amount) * (Decimal(10) ** 9) # Gigaweis are billions
eth_amount = web3.fromWei(wei_amount,'ether')
return wei_amount, eth_amount
If you don't mind importing another library, Brownie's Wei class makes it very simple to get from gwei to wei:
>>> from brownie import Wei
>>> Wei("1 gwei")
1000000000