Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

01%20python/04.06%20%EB%8D%B0%EC%9D%B4%ED%84%B0%ED%94%84%EB%A0%88%EC%9E%84%20%ED%95%A9%EC%84%B1 #63

Open
utterances-bot opened this issue May 29, 2022 · 2 comments

Comments

@utterances-bot
Copy link

4.6 데이터프레임 합성 — 데이터 사이언스 스쿨

https://datascienceschool.net/01%20python/04.06%20%EB%8D%B0%EC%9D%B4%ED%84%B0%ED%94%84%EB%A0%88%EC%9E%84%20%ED%95%A9%EC%84%B1.html

Copy link

np.random.seed(0)
df1=pd.DataFrame(np.random.randint(1,15,size=(2,6)),columns=[i for i in range(1,7)],index=['매출','비용'])
df2=pd.DataFrame(np.random.randint(1,20,size=(2,6)),columns=[i for i in range(7,13)],index=['매출','비용'])
df3=pd.concat([df1,df2],axis=1)
df3.loc['이익']=df3.apply(lambda x:int(x.loc['매출'])-int(x.loc['비용']))
df3['총실적']=[sum(df3.loc['매출']),sum(df3.loc['비용']),sum(df3.loc['이익'])]
df3

Copy link

lysnjn commented Aug 7, 2022

np.random.seed(0)
df_result1 = pd.DataFrame(np.random.randint(-100,100, (6,2)), columns=['매출', '비용'], index=[str(i+1) +'월' for i in range(6)])
df_result2 = pd.DataFrame(np.random.randint(-100,100, (6,2)), columns=['매출', '비용'], index=[str(i+7) +'월' for i in range(6)])
df_result3 = pd.concat([df_result1, df_result2])
df_result3['이익'] = df_result3['매출'] - df_result3['비용']
df_result3.loc[('총 실적'),:] = df_result3.sum()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants