Skip to content

Pandas get_dummies validate "columns" input #28383

Closed
@TonyCongqianWang

Description

@TonyCongqianWang

Code Sample, a copy-pastable example if possible

import string, pandas

p_csv = pandas.read_csv(my_dir/myFile), index_col=0)

sepanames = sorted(p_csv["SEPARATOR"].unique())

for i in range(0, 14):
print(i)
col = p_csv.columns.get_loc("SEPARATOR") + 1 + i
p_csv.insert(col, "SEPARATOR_" + sepanames[i].upper(), p_csv["SEPARATOR"].apply(lambda x: int(x == sepanames[i])))

p_csv.to_csv("my_dir/new_file.csv")

''' p_csv= pandas.read_csv(("/myDir/myFile.csv"), index_col=0)
pandas.get_dummies(p_csv, prefix="SEPARATOR_", columns="SEPARATOR")
p_csv.to_csv("/myDir/myNew.csv")'''

FILES:
https://www.amazon.de/clouddrive/share/h37d1hqtrj5SrZTvKdrs9gXltVKUgo8Is9BxL8WH7Sf

Problem description

This is all of my code. The quoted part is what I first tried, but after 20 minutes it ended through a sigkill without any result. The required files are available for download. I would think, that my code does the equivalent in this very case and it works just fine in under about a minute.

Pandas Version: 25.1.0
Pandas git version: '171c71611886aab8549a8620c5b0071a129ad685'

Expected Output

No error and changed csv file

Metadata

Metadata

Assignees

No one assigned

    Labels

    API DesignError ReportingIncorrect or improved errors from pandasReshapingConcat, Merge/Join, Stack/Unstack, Explode

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions