Over my summer break I am taking baby steps in Python - using PyCharm Community 2020.3
I thought I would start out looking at my last three months of Greyhound Data, so I downloaded that in csv format from my Betfair P&L page.
Those familiar will know that the first column of the csv data is very messy and so I have created a short program to clean it up and prepare a revised excel spreadsheet.
In order to run the program you will need PyCharm Community 2020.3, you will need to have pandas and openpyxl installed and have excel.
After downloading my betfair data I named it "hounds.csv" and put it in the same folder as my PyCharm project. You will see in the red text below you will need to insert your own username into the pathway.
I plan to create a program to analyse this data.
Hope this is helfpul.
/////
import pandas as pd
df = pd.read_csv('hounds.csv')
df.dropna(inplace = True)
df.drop(columns=['Start time', 'Settled date'])
header_list = ['Market', 'Track', 'Date', 'Race', 'Length', 'Profit/Loss (AUD)']
df = df.reindex(columns=header_list)
new = df["Market"].str.split("/", n = 1, expand = True)
df['Market']=new[0]
newc=new[1].str.split(" ", n=2, expand=True)
df['Track']=newc[1]
newc=newc[2].str.split(":", expand=True)
newc['Date']=newc[0].str[-9:]
df['Date']=newc['Date']
newc['Race']=newc[1].str[:3]
df['Race']=newc['Race']
newc['Length']=newc[1].str[4:9]
df['Length']=newc['Length']
df.to_excel (r'C:\Users\XXXX\Desktop\export_dataframe.xlsx', index = False, header=True)
Python CSV Clean Up for Greyhounds
-
- Posts: 3140
- Joined: Sun Jan 31, 2010 8:06 pm
Same here, Dallas. I use VBA to parse the data files but always good to learn something new. I started learning python about a year ago but got knocked off track when covid shut everything down. Hopefully get back into coding in the new yer.
Had to really fiddle with my pycharm interpreter and working directory (which helped a lot with understanding) to get this to work. Been whiling away my hours with some python learning but chemo and old brain makes for hard yakka
Thanks for this gazuty. Look forward to using pandas+python more so I can at least follow what you did
Thanks for this gazuty. Look forward to using pandas+python more so I can at least follow what you did
Well done McGoo. Hope you beat that bastard cancer. One day we will die, but every day before then we will live. Carpe diem.mcgoo wrote: ↑Sat Jan 02, 2021 1:05 amHad to really fiddle with my pycharm interpreter and working directory (which helped a lot with understanding) to get this to work. Been whiling away my hours with some python learning but chemo and old brain makes for hard yakka
Thanks for this gazuty. Look forward to using pandas+python more so I can at least follow what you did
Gazuty
This is a great little course (dont pay more than 12 GBP for it though
Regards
Peter
https://www.udemy.com/course/python-for-excel-users/
This is a great little course (dont pay more than 12 GBP for it though
Regards
Peter
https://www.udemy.com/course/python-for-excel-users/