大家好!
这里是关于IT技术的内容。dict = {'Awesome' : 'Sauce', 'Foo' : 'Barr'}
Col A Col B
1 'This is Awesome'
2 'I really foo him'
我正在尝试找到最符合Python风格的方法来迭代数据集/框架,并返回与字典值匹配的任何字符串。
例如,对于第一项,我想返回列c中的“Sauce”,对于第二项,在相应的行中但在列c中返回“barr”。
如果有必要,我正在处理CSV / Excel文件。
感谢任何帮助。我很高兴使用Pandas和NP库。
ID Name of Course
0 Super Event Training: English Event...
1 Start with our Maths Training...
2 Live online Biology Training...
3 Maths throughout time...
4 Online Q&A Webinar: History..
5 Start with our Creative ...
6 Spring Conf with Author
7 Physics in our age ...
8 Spring Conf
9 Start with our educational items...
10 Education delivery in India...
11 English IELTS, Access to University..
12 Our Core Products for Empowerment..
我有一个类似这样的DF,大约有500行,我正在使用API进行爬取,需要将此自由格式文本转换为我的字典中的值。我已经识别出关键词并将其放入我的键值中,并分配给字典值,以便我们可以分析数据。
也许使用字典不是做这件事情的最佳方式?任何建议将不胜感激。
DN.