-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Append Datafarmes #6806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @pi-curst , I would say that this is expected behavior. Append method gets IEnumerable rows as an argument. Internaly for each row in the provided sequence this method calls Append(IEnumerable row). So for each DataFrameRow object IEnumerable is called and it works based on column position in DataFrame.Columns collection (column index), column names are just ignored:
So actualy your code looks similar to this:
|
However, I checked the same behaviour in pandas dataframe and it works as you expected:
Result:
@JakeRadMSFT, @luisquintanilla what do you think? Should it be changed inline with Pandas behavior? |
Hi @asmirnov82, Thanks for the replies and investigations. I can see why it works the way it does now, but I too would expect that if the column names are the same, appending two DataFrames would require that their column names match up and by extension would append the values based on the column names. @JakeRadMSFT thoughts? |
System Information (please complete the following information):
Describe the bug
Hi, Appending Dataframes (DataFrame.Append Method) doesn't seem to append based on column names, but appends based on the position. Is this normal?
To Reproduce
`var data = new DataFrame();
var col1 = new StringDataFrameColumn("ColumnA", new string[] { "a", "b", "c", "d", "e" });
var col2 = new Int32DataFrameColumn("ColumnB", new int[] { 1, 2, 3, 4, 5 });
var col3 = new Int32DataFrameColumn("ColumnC", new int[] { 10, 20, 30, 40, 50 });
var col4 = new StringDataFrameColumn("ColumnA", new string[] { "f", "g", "c", "d", "e" });
var col5 = new Int32DataFrameColumn("ColumnB", new int[] { 6, 7, 3, 4, 5 });
var col6 = new Int32DataFrameColumn("ColumnC", new int[] { 100, 200, 300, 400, 500 });
var dataFrame1 = new DataFrame(col1, col2, col3);
var dataFrame2 = new DataFrame(col4, col6, col5);
var dataFrames = new List { dataFrame1, dataFrame2 };
var resultDataFrame = dataFrame1.Append(dataFrame2.Rows);`
Exhibited behavior
Expected behavior
The text was updated successfully, but these errors were encountered: