Skip to content

BUG: Selecting the wrong first column #61253

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

Closed
2 of 3 tasks
morzen opened this issue Apr 8, 2025 · 1 comment
Closed
2 of 3 tasks

BUG: Selecting the wrong first column #61253

morzen opened this issue Apr 8, 2025 · 1 comment
Labels
Bug IO CSV read_csv, to_csv

Comments

@morzen
Copy link

morzen commented Apr 8, 2025

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

TTP_CWE_mappingDF = pd.read_csv('./658.csv', sep=',')

columns_list = TTP_CWE_mappingDF.columns.tolist()  # Returns column names as a list
print(columns_list)
print("\n")


TEST = TTP_CWE_mappingDF.iloc[:, [0]]



columns_list2 = TEST.columns.tolist()  # Returns column names as a list
print(columns_list2)

print(TEST)

# first_column = TTP_CWE_mappingDF.iloc[:, 0]  # All rows (:) + first column (0)
# print(first_column)

Issue Description

Hi,

When downloading the MITRE CAPEC cwe .csv I tried to import it on Python to play with it a bit.
Surprisingly, when selecting the first column, the data is from the second column, and this applies to the whole dataframe; all columns are off by one. The key is correct, but the data is for the next key.

This is rather problematic, as you can imagine.

I added the .csv file I am using as well.

658.csv

Expected Behavior

this is the result i get:

["'ID", 'Name', 'Abstraction', 'Status', 'Description', 'Alternate Terms', 'Likelihood Of Attack', 'Typical Severity', 'Related Attack Patterns', 'Execution Flow', 'Prerequisites', 'Skills Required', 'Resources Required', 'Indicators', 'Consequences', 'Mitigations', 'Example Instances', 'Related Weaknesses', 'Taxonomy Mappings', 'Notes']

["'ID"]
'ID
1 Accessing Functionality Not Properly Constrain...
11 Cause Web Server Misclassification
112 Brute Force
114 Authentication Abuse
115 Authentication Bypass
.. ...
698 Install Malicious Extension
70 Try Common or Default Usernames and Passwords
700 Network Boundary Bridging
94 Adversary in the Middle (AiTM)
98 Phishing

[177 rows x 1 columns]

the expected result should be:

["'ID", 'Name', 'Abstraction', 'Status', 'Description', 'Alternate Terms', 'Likelihood Of Attack', 'Typical Severity', 'Related Attack Patterns', 'Execution Flow', 'Prerequisites', 'Skills Required', 'Resources Required', 'Indicators', 'Consequences', 'Mitigations', 'Example Instances', 'Related Weaknesses', 'Taxonomy Mappings', 'Notes']

["'ID"]
'ID
1
11
112
114
115
..
698
70
700
94
98

[177 rows x 1 columns]

Installed Versions

INSTALLED VERSIONS

commit : 0691c5c
python : 3.12.7
python-bits : 64
OS : Linux
OS-release : 6.8.11-arm64
Version : #1 SMP Kali 6.8.11-1kali2 (2024-05-30)
machine : aarch64
processor :
byteorder : little
LC_ALL : None
LANG : C.UTF-8
LOCALE : C.UTF-8

pandas : 2.2.3
numpy : 2.2.4
pytz : 2025.2
dateutil : 2.9.0.post0
pip : 24.1.1
Cython : None
sphinx : None
IPython : 9.0.2
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.13.3
blosc : None
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : None
html5lib : None
hypothesis : None
gcsfs : None
jinja2 : 3.1.6
lxml.etree : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
psycopg2 : None
pymysql : None
pyarrow : None
pyreadstat : None
pytest : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlsxwriter : None
zstandard : None
tzdata : 2025.2
qtpy : None
pyqt5 : None

@morzen morzen added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Apr 8, 2025
@rhshadrach
Copy link
Member

Thanks for the report. If you would like pandas to not infer the first values as an index, you can pass index_col=False to read_csv.

Closing for now. If this doesn't resolve your issue, reply here as to why and we can reopen.

@rhshadrach rhshadrach added IO CSV read_csv, to_csv and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Apr 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug IO CSV read_csv, to_csv
Projects
None yet
Development

No branches or pull requests

2 participants