Пример #1
0
def test_stringToDate1():
	testing_df = df.copy()
	testing_df['col3'] = pd.Series(['01/01/2000', '10/01/1995'])
	assert testing_df['col3'].dtype == 'object'
	load.changeColumnDataType(testing_df, 'col3', 'datetime64')
	print testing_df['col3'].dtype
	assert testing_df['col3'].dtype == 'datetime64[ns]'
Пример #2
0
def test_intToString():
	testing_df = df.copy()
	newType = np.dtype('int64')
	testing_df['col2'] = testing_df['col2'].astype(newType)
	assert testing_df['col2'].dtype == 'int64'
	load.changeColumnDataType(testing_df, 'col2', 'str')
	assert testing_df['col2'].dtype == 'object'
Пример #3
0
def test_intToFloat1():
	testing_df = df.copy()
	newType = np.dtype('int64')
	testing_df['col2'] = testing_df['col2'].astype(newType)
	assert testing_df['col2'].dtype == 'int64'
	load.changeColumnDataType(testing_df, 'col2', 'float64')
	assert testing_df['col2'].dtype == 'float64'
Пример #4
0
def test_stringToInt2():
	testing_df = df.copy()
	testing_df['col3'] = pd.Series(['1'], index = [0])
	with pytest.raises(Exception):
		load.changeColumnDataType(testing_df, 'col3', 'int64')
Пример #5
0
def test_stringToInt1():
	testing_df = df.copy()
	testing_df['col3'] = pd.Series(['1', '2'], index = [0, 1])
	assert testing_df['col3'].dtype == 'object'
	load.changeColumnDataType(testing_df, 'col3', 'int64')
	assert testing_df['col3'].dtype == 'int64'
Пример #6
0
def test_floatToString1():
	testing_df = df.copy()
	assert testing_df['col1'].dtype == 'float64'
	load.changeColumnDataType(testing_df, 'col1', 'str')
	assert testing_df['col1'].dtype == 'object'
Пример #7
0
def test_floatToInt2():
	testing_df = df.copy()
	assert testing_df['col1'].dtype == 'float64'
	with pytest.raises(Exception):
		load.changeColumnDataType(testing_df, 'col1', 'int64')
Пример #8
0
def test_floatToInt1():
	testing_df = df.copy()
	assert testing_df['col2'].dtype == 'float64'
	load.changeColumnDataType(testing_df, 'col2', 'int64')
	assert testing_df['col2'].dtype == 'int64'