Pandas: printing to csv also creates an unlabelled column with row indices
up vote
0
down vote
favorite
I use the following code to print a dataframe into a csv file based on the answers seen at this question:
How to avoid Python/Pandas creating an index in a saved csv?
y_insincere = [classify_text(text,trimmed_posterior_dict)<0 for text in X_test]
X_output = pd.DataFrame()
X_output['number'] = number
X_output['CASE'] = case
X_output.to_csv('submission.csv',header=True,columns = ['id','case'],index='False')
However, when I look at the csv file it has an extra column without a header with row indices. I tried other fixes from the above question, but nothing worked. I am stuck. Any help appreciated
pandas csv
New contributor
add a comment |
up vote
0
down vote
favorite
I use the following code to print a dataframe into a csv file based on the answers seen at this question:
How to avoid Python/Pandas creating an index in a saved csv?
y_insincere = [classify_text(text,trimmed_posterior_dict)<0 for text in X_test]
X_output = pd.DataFrame()
X_output['number'] = number
X_output['CASE'] = case
X_output.to_csv('submission.csv',header=True,columns = ['id','case'],index='False')
However, when I look at the csv file it has an extra column without a header with row indices. I tried other fixes from the above question, but nothing worked. I am stuck. Any help appreciated
pandas csv
New contributor
X_output.to_csv('submission.csv',header=True,columns = ['id','case'],index=False)
'False'
is notFalse
in pandas
– W-B
2 days ago
@W-B Oops.That must be the error. Thank you! Wonder why it didn't throw an error.
– Arun
yesterday
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I use the following code to print a dataframe into a csv file based on the answers seen at this question:
How to avoid Python/Pandas creating an index in a saved csv?
y_insincere = [classify_text(text,trimmed_posterior_dict)<0 for text in X_test]
X_output = pd.DataFrame()
X_output['number'] = number
X_output['CASE'] = case
X_output.to_csv('submission.csv',header=True,columns = ['id','case'],index='False')
However, when I look at the csv file it has an extra column without a header with row indices. I tried other fixes from the above question, but nothing worked. I am stuck. Any help appreciated
pandas csv
New contributor
I use the following code to print a dataframe into a csv file based on the answers seen at this question:
How to avoid Python/Pandas creating an index in a saved csv?
y_insincere = [classify_text(text,trimmed_posterior_dict)<0 for text in X_test]
X_output = pd.DataFrame()
X_output['number'] = number
X_output['CASE'] = case
X_output.to_csv('submission.csv',header=True,columns = ['id','case'],index='False')
However, when I look at the csv file it has an extra column without a header with row indices. I tried other fixes from the above question, but nothing worked. I am stuck. Any help appreciated
pandas csv
pandas csv
New contributor
New contributor
edited 2 days ago
CJ59
867113
867113
New contributor
asked 2 days ago
Arun
1012
1012
New contributor
New contributor
X_output.to_csv('submission.csv',header=True,columns = ['id','case'],index=False)
'False'
is notFalse
in pandas
– W-B
2 days ago
@W-B Oops.That must be the error. Thank you! Wonder why it didn't throw an error.
– Arun
yesterday
add a comment |
X_output.to_csv('submission.csv',header=True,columns = ['id','case'],index=False)
'False'
is notFalse
in pandas
– W-B
2 days ago
@W-B Oops.That must be the error. Thank you! Wonder why it didn't throw an error.
– Arun
yesterday
X_output.to_csv('submission.csv',header=True,columns = ['id','case'],index=False)
'False'
is not False
in pandas– W-B
2 days ago
X_output.to_csv('submission.csv',header=True,columns = ['id','case'],index=False)
'False'
is not False
in pandas– W-B
2 days ago
@W-B Oops.That must be the error. Thank you! Wonder why it didn't throw an error.
– Arun
yesterday
@W-B Oops.That must be the error. Thank you! Wonder why it didn't throw an error.
– Arun
yesterday
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Arun is a new contributor. Be nice, and check out our Code of Conduct.
Arun is a new contributor. Be nice, and check out our Code of Conduct.
Arun is a new contributor. Be nice, and check out our Code of Conduct.
Arun is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53402428%2fpandas-printing-to-csv-also-creates-an-unlabelled-column-with-row-indices%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
X_output.to_csv('submission.csv',header=True,columns = ['id','case'],index=False)
'False'
is notFalse
in pandas– W-B
2 days ago
@W-B Oops.That must be the error. Thank you! Wonder why it didn't throw an error.
– Arun
yesterday