Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- from datetime import datetime
- from pytz import timezone
- def est_to_utc(date_str):
- datetime_obj = datetime.strptime(date_str, "%m/%d/%y %H:%M")
- datetime_obj_utc = datetime_obj.replace(tzinfo=timezone('UTC'))
- return datetime_obj_utc.strftime("%Y-%m-%d %H:%M:%S %Z%z")
- def convert_utc():
- cost_df = pd.read_csv("cost_1.csv")
- revenue_df = pd.read_csv("revenue_1.csv")
- cost_df["utc"] = cost_df["data_date"].apply(lambda x: est_to_utc(x))
- cost_df.to_csv("cost_utc.csv")
- revenue_df["utc"] = revenue_df["data_date"].apply(lambda x: est_to_utc(x))
- revenue_df.to_csv("revenue_utc.csv")
- if __name__ == '__main__':
- convert_utc()
- revenue_df = pd.read_csv("revenue_utc.csv")
- cost_df = pd.read_csv("cost_utc.csv")
- # x = revenue_df[:10].set_index('campaign_id').join(cost_df[:10]).set_index('campaign_id'))
- small = revenue_df[:10].merge(cost_df[:10], left_on=['campaign_id'], right_on='campaign_id').groupby({'uv'})
- small['uv'] = small["revenue"] / small["clicks"]
- small["cpc"] = small["costs"] / small["clicks"]
- small["roi"] = small["uv"] / small["cpc"]
- small["profit"] = small["revenue"] - small["cost"]
- pass
- ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement