Skip to content

Column names disappearing from Dataframe after MinMaxScaler transform. #323

Answered by KingWebsites
KingWebsites asked this question in Q&A
Discussion options

You must be logged in to vote

I've now collected my code and simplified it. Here's the function I use to normalise the data within each column and then return a dataset with the same column names and indexes.

I'd still be interested in hearing about other ways of doing this.

normaliseDataFrame(dataFrame)
{

	// Normalise values in dataFrame

	// Normalising removes DataFrame titles and row dates so we need to extract

	let indexes = dataFrame.index;
	let columnTitles = dataFrame.columns;

	// Normalise DataFrame using temp dataFrame
	let scaler = new dfd.MinMaxScaler();
	let tempDataFrame = scaler.fit(dataFrame);

	// Add column titles and row dates back
	tempDataFrame.set_index({
		index: indexes,
		inplace: true
	})…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by KingWebsites
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant