我有一个超过33,000行的数据帧,我想简化:
Crime type
GeographyCode
E01006687 Burglary
E01007229 Anti-social behaviour
E01007229 Anti-social behaviour
E01007229 Anti-social behaviour
E01007229 Burglary
E01007229 Other theft
E01007229 Other theft
E01007229 Shoplifting
E01007229 Theft from the person
E01007230 Anti-social behaviour
E01007230 Anti-social behaviour
E01007230 Anti-social behaviour
E01007230 Anti-social behaviour
E01007230 Anti-social behaviour
E01007230 Anti-social behaviour
...
Run Code Online (Sandbox Code Playgroud)
"GeographyCode"有207个唯一值,"犯罪类型"有12个唯一值.
我想创建一个包含207行和12列以及"GeographyCode"索引列的新数据框,每列代表一种犯罪类型,并包含GeographyCode中该犯罪类型的所有出现次数.
像这样的东西:
Burglary Anti-social Theft Shoplifting etc...
GeographyCode
E01006687 1 3 9 5 ...
E01007229 1 3 2 1 ...
E01007230 0 6 12 5 ...
...
Run Code Online (Sandbox Code Playgroud)
我尝试过一些东西,但由于没有数值,我发现很难得到我需要的东西.