AutoSkill Custom Python DataFrame Implementation
Implement a custom DataFrame class in Python with specific methods (__init__, __getitem__, __repr__, etc.) that handles list-based data initialization and returns CSV-formatted strings for multi-column access.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt4_8/custom-python-dataframe-implementation" ~/.claude/skills/ecnu-icalk-autoskill-custom-python-dataframe-implementation && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt4_8/custom-python-dataframe-implementation/SKILL.mdsource content
Custom Python DataFrame Implementation
Implement a custom DataFrame class in Python with specific methods (init, getitem, repr, etc.) that handles list-based data initialization and returns CSV-formatted strings for multi-column access.
Prompt
Role & Objective
You are a Python developer tasked with implementing a custom
DataFrame class and a helper ListV2 class. The implementation must adhere to specific method signatures and output formatting requirements.
Operational Rules & Constraints
-
Class Structure:
- ListV2: A wrapper class for a list, implementing
and__iter__
.__next__ - DataFrame:
: Initialize__init__(self, data, columns)
(dict),self.index
(dict ofself.data
objects), andListV2
(list). Handleself.columns
as a list of lists (rows) anddata
as a tuple/list. Populatecolumns
by iterating through rows and zipping with columns.self.data
: Set the index from a column name.set_index(self, index)
: Add or update a column.__setitem__(self, col_name, values)
:__getitem__(self, col_name)- If
is a string, return the list of values for that column.col_name - If
is a list of strings, return a CSV-formatted string of those columns with an index.col_name
- If
: Retrieve a row by index label.loc(self, row_name)
: Iterate over columns.iteritems(self)
: Iterate over rows.iterrows(self)
: Convert data types.as_type(self, dtype, col_name)
: Remove a column.drop(self, col_name)
: Calculate mean of columns.mean(self)
: Return a CSV-formatted string of the entire DataFrame.__repr__(self)
- ListV2: A wrapper class for a list, implementing
-
Output Formatting:
- String representations (from
and list-based__repr__
) must be comma-separated values.__getitem__ - The first column header must be an empty string (e.g.,
).",Col1,Col2" - The first column of data rows must be the row index (integer).
- Ensure tuple/list concatenation is handled correctly in
(e.g.,__repr__
).("",) + self.columns
- String representations (from
Anti-Patterns
- Do not use pandas or external libraries.
- Do not assume
is always a list; handle tuples.self.columns - Do not return a DataFrame object when
receives a list of columns; return a formatted string.__getitem__
Triggers
- implement a dataframe class
- custom dataframe python
- dataframe with getitem and repr
- python dataframe assignment
- ListV2 dataframe