grouping on tems in a list in python

2024/10/11 14:21:13

I have 60 records with a column "skillsList" "("skillsList" is a list of skills) and "IdNo". I want to find out how many "IdNo's" have a skill in common.

How can I do it in python. I am not knowing how to take the count of a particular list item. Would appreciate any help.

>>> a = open("C:\Users\abc\Desktop\Book2.csv")
>>> type(a1)
<type 'str'>

Some of the text when I print a1

>>> a1
'IdNo, skillsList\n1,"u\'Training\', u\'E-Learning\', u\'PowerPoint\', u\'Teaching\', u\'Accounting\', u\'Team Management\', u\'Team Building\', u\'Microsoft Excel\', u\'Microsoft Office\', u\'Financial Accounting\', u\'Microsoft Word\', u\'Customer Service\'"\n2,"u\'Telecommunications\', u\'Data Center\', u\'ISO 27001\', u\'Management\', u\'BS25999\', u\'Technology\', u\'Information Technology...\', u\'Certified PMP\\xae\', u\'Certified BS25999 Lead...\'"\n3,"u\'Market Research\', u\'Segmentation\', u\'Marketing Strategy\', u\'Consumer Behavior\', u\'Experience Working with...\'"

Thanks

Answer

You have to do it by yourself. you may use a dictionnary of skills , each item of the dic beeing inited to zero. Then iterate over your records and increment skill item when seen.

https://en.xdnf.cn/q/118316.html

Related Q&A

How do I show a suffix to user input in Python?

I want a percentage sign to display after the users enters their number. Thankspercent_tip = float(input(" Please Enter the percent of the tip:")("%"))For example, before the user t…

Discord.py Self Bot using rewrite

Im trying to make a selfbot using discord.py rewrite. Im encountering issues when attempting to create a simple command. Id like my selfbot to respond with "oof" when ">>>test&q…

int to binary python

This question is probably very easy for most of you, but i cant find the answer so far.Im building a network packet generator that goes like this:class PacketHeader(Packet): fields = OrderedDict([(&quo…

Get aiohttp results as string

Im trying to get data from a website using async in python. As an example I used this code (under A Better Coroutine Example): https://www.blog.pythonlibrary.org/2016/07/26/python-3-an-intro-to-asyncio…

Waiting for a timer to terminate before continuing running the code

The following code updates the text of a button every second after the START button was pressed. The intended functionality is for the code to wait until the timer has stopped before continuing on with…

PySpark: how to resolve path of a resource file present inside the dependency zip file

I have a mapPartitions on an RDD and within each partition, a resource file has to be opened. This module that contains the method invoked by mapPartitions and the resource file is passed on to each ex…

Convert normal Python script to REST API

Here I have an excel to pdf conversion script. How can I modify it to act as a REST API? import os import comtypes.client SOURCE_DIR = D:/projects/python TARGET_DIR = D:/projects/python app = comtypes…

How to track changes in specific registry key or file with Python? [closed]

Closed. This question is seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. It does not meet Stack Overflow guidelines. It is not currently accepting …

How to use Android NDK to compile Numpy as .so?

Because the Numpy isnt a static library(it contains .py files, .pyc files, .so files, etc), so if I want to import it to my python code which is used in an Android phone(using CLE), I should recompile …

passing boolean function to if-condition in python

I"m learning python, and Im trying to do this, which I thought should be trivial, but apparently, its not. $python >>> def isTrue(data): ... "ping" in data ... >>>…