ENH: specify header=['list', 'of', 'headers'] in DataFrame.write_csv() · Issue #921 · pandas-dev/pandas (original) (raw)
Navigation Menu
- GitHub Copilot Write better code with AI
- GitHub Models New Manage and compare prompts
- GitHub Advanced Security Find and fix vulnerabilities
- Actions Automate any workflow
- Codespaces Instant dev environments
- Issues Plan and track work
- Code Review Manage code changes
- Discussions Collaborate outside of code
- Code Search Find more, search less
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Description
As with R's write.table col.names which can take a list of column headers to output instead of the
headers.
here's a start, though I'm unsure about hwo it interacts with the index label stuff.
diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 248a4e9..8c93488 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -13,7 +13,7 @@ labeling information
pylint: disable=E1101,E1103
pylint: disable=W0212,W0231,W0703,W0622
- +import collections from itertools import izip from StringIO import StringIO import csv @@ -889,7 +889,9 @@ class DataFrame(NDFrame): cols = self.columns series = self._series
if header:
if isinstance(header, collections.Iterable):
writer.writerow([h or '' for h in header])
elif header: if index: # should write something for index label if index_label is None: