<commit_before>import db

from time import mktime
from datetime import datetime
from pandas import DataFrame

#			start = datetime.strptime(start, "%m/%d/%y")		
#			start = int(mktime(start.timetuple()))	


class trades(object):
	
	def __init__(self):
		self.df = DataFrame(columns=('tid','price','amount','type', 'exchange',
																'timestamp','timestamp_ms','dbtable'))
		self.ts = DataFrame(columns=('timestamp','price','high',
																 'low','open','amount'))

	def add(self, table, exchange=''):
		data = db.trade_data(table, exchange=exchange)
		data = db.date_index(data)
		data['dbtable'] = table
		self.df = self.df.append(data)
		self.df = self.df.sort()

	def time_series(self, period):
		tmin = int(self.df['timestamp'].min())
		tmax = int(self.df['timestamp'].max())
		for tsmp in range(tmin, tmax, period):
			df, slic = time_slice(self.df, tsmp, period)		
			self.ts = self.ts.append(slic)
		self.ts = db.date_index(self.ts)

def time_slice(df, tsmp, period):
	lprice = df[df['timestamp'] < tsmp].tail(1)['price']
	df = df[df['timestamp'] >= tsmp]
	df = df[df['timestamp'] < (tsmp + period)]	
	if len(df.index) == 0:
		slic = DataFrame({'timestamp' : [tsmp], 'price': lprice, 
										'high': lprice, 'low': lprice,
										'open': lprice, 'amount': 0.0})		
	else:			
		slic = DataFrame({'timestamp' : [tsmp], 
										'price': round(df['price'].iloc[-1], 3),
										'high': round(df['price'].max(), 3), 
										'low': round(df['price'].min(), 3),
										'open': round(df['price'].iloc[0], 3), 
										'amount': round(df['amount'].sum(), 4)})		
	return df, slic



		
<commit_msg>Fixed indents on 'slic' functions<commit_after>import db

from time import mktime
from datetime import datetime
from pandas import DataFrame

#			start = datetime.strptime(start, "%m/%d/%y")		
#			start = int(mktime(start.timetuple()))	


class trades(object):
	
	def __init__(self):
		self.df = DataFrame(columns=('tid','price','amount','type', 'exchange',
																'timestamp','timestamp_ms','dbtable'))
		self.ts = DataFrame(columns=('timestamp','price','high',
																 'low','open','amount'))

	def add(self, table, exchange=''):
		data = db.trade_data(table, exchange=exchange)
		data = db.date_index(data)
		data['dbtable'] = table
		self.df = self.df.append(data)
		self.df = self.df.sort()

	def time_series(self, period):
		tmin = int(self.df['timestamp'].min())
		tmax = int(self.df['timestamp'].max())
		for tsmp in range(tmin, tmax, period):
			df, slic = time_slice(self.df, tsmp, period)		
			self.ts = self.ts.append(slic)
		self.ts = db.date_index(self.ts)

def time_slice(df, tsmp, period):
	lprice = df[df['timestamp'] < tsmp].tail(1)['price']
	df = df[df['timestamp'] >= tsmp]
	df = df[df['timestamp'] < (tsmp + period)]	
	if len(df.index) == 0:
		slic = DataFrame({'timestamp' : [tsmp], 'price': lprice, 
				'high': lprice, 'low': lprice,
				'open': lprice, 'amount': 0.0})		
	else:			
		slic = DataFrame({'timestamp' : [tsmp], 
				'price': round(df['price'].iloc[-1], 3),
				'high': round(df['price'].max(), 3), 
				'low': round(df['price'].min(), 3),
				'open': round(df['price'].iloc[0], 3), 
				'amount': round(df['amount'].sum(), 4)})		
	return df, slic



		

{'fraction_non_alphanumeric': 0.20444718962322422, 'fraction_numerical': 0.0067943174799258805, 'mean_word_length': 3.7284671532846714, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6050011', 'n_tokens_mistral': 1401, 'n_tokens_neox': 1168, 'n_words': 242}