Issue
def divis(data):
data['prom'] = data['total']/data['num2']
return data
async def divis(data):
data['prom'] = await (data['total']/data['num2'])
return data
await divis(df2)
TypeError: unhashable type: 'Series'
Solution
Based on the question fastest way to apply an async function to pandas dataframe and its accepted answer, this will look like:
import asyncio
import numpy as np
import pandas as pd
async def fun2(x, y):
return x / y
async def divis(data):
data['prom'] = await asyncio.gather(*(fun2(x, y) for x, y in zip(data['total'], data['num2'])))
return data
await divis(df2)
Answered By - Michael Butscher
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.