Merge Files based on primary key, and sort
Jump to navigation
Jump to search
import pandas as pd import plotly.express as px slack_analy = pd.read_csv('slack_anl.csv') slack_members = pd.read_csv('slack_members.csv') ## merge sheets on username column df_merge = slack_members.merge(slack_analy, on='username') ## choose which column to display select_columns = df_merge[['username', 'Days active','Included in bill', 'Messages posted']] ## separate members with post more than 0 active_posts = select_columns.where(select_columns['Messages posted']>0).dropna() active_post = active_posts.sort_values(by=['Messages posted'], inplace=True, ascending=False) ## included in bill extraction billed = select_columns.where(select_columns['Included in bill']>0).dropna() ## displays only those 2 columns show_billed = billed[['username', 'Messages posted']] print(show_billed) #print(billed) print(active_posts) #print(select_columns) #print(df_merge) #print(slack_analy, slack_members) active_posts.shape billed.shape fig = px.pie(active_posts[['username', 'Messages posted']], values='Messages posted', names='username') #fig.show() #active_posts.to_excel('export.xlsx', index=False)
Excel files are in: G:\Dropbox\All Folders\python\python_desktop\myproj-merge1