考虑我有一个df:
Product Category
Bill Payment for Torrent Power Limited
Recharge of Videocon d2h DTH
Bill Payment of Airtel Mobile
Recharge of Idea Mobile
Run Code Online (Sandbox Code Playgroud)
现在,如果一个字符串包含“Bill Payment”和“Mobile”,那么我想将其类别标记为“Postpaid”,如果一个字符串包含“Recharge”和“Mobile”,我想将其标记为“Prepaid”。
我是 R 的初学者,因此将不胜感激最简单的方法。
结果应该是
Product Category
Bill Payment for Torrent Power Limited NA
Recharge of Videocon d2h DTH NA
Bill Payment of Airtel Mobile Postpaid
Recharge of Idea Mobile Prepaid
Run Code Online (Sandbox Code Playgroud) 这些表达是什么意思?我在哪里可以了解它们的用法?
\\d
\\D
\\s
\\S
\\w
\\W
\\t
\\n
^
$
\
| etc..
Run Code Online (Sandbox Code Playgroud)
我需要使用这个stringr包,我完全不知道如何使用这些。
考虑我有一个df
> editor
A B C D E F G H I J
User1 1 0 5 6 5 6 5 6 2 6
User2 0 5 4 6 4 5 5 1 7 5
Run Code Online (Sandbox Code Playgroud)
我想在上面的行中存储第一个出现的第二大值的列名.预期成绩
> editor
A B C D E F G H I J 2nd_highest
User1 1 0 5 6 5 6 5 6 2 6 C
User2 0 5 4 6 4 5 5 1 7 5 D
Run Code Online (Sandbox Code Playgroud)
我试过,edited$2nd_highest <- colnames(edited)[apply(edited, 1, which.max)+1]但没有运作良好. …
当我试图安装pyAudio使用pip install pyaudio,我得到的错误。看起来像这样:
C:\Users\pankajkaun>pip install pyaudio
Collecting pyaudio
Using cached https://files.pythonhosted.org/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-0.2.11.tar.gz
Installing collected packages: pyaudio
Running setup.py install for pyaudio ... error
Complete output from command c:\users\pankajkaun\desktop\python\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\PANKAJ~1\\AppData\\Local\\Temp\\pip-install-pw8_ueh5\\pyaudio
\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\PANKAJ~1\AppData\Local\Temp
\pip-record-eru_9orv\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.7
copying src\pyaudio.py -> build\lib.win-amd64-3.7
running build_ext
building '_portaudio' extension
creating build\temp.win-amd64-3.7
creating build\temp.win-amd64-3.7\Release
creating build\temp.win-amd64-3.7\Release\src
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe /c /nologo …Run Code Online (Sandbox Code Playgroud) 我有两个dfs如下
>codes1
Country State City Start No End No
IN Telangana Hyderabad 100 200
IN Maharashtra Pune (Bund Garden) 300 400
IN Haryana Gurgaon 500 600
IN Maharashtra Pune 700 800
IN Gujarat Ahmedabad (Vastrapur) 900 1000
Run Code Online (Sandbox Code Playgroud)
现在我想标记表1中的ip地址
>codes2
ID No
1 157
2 346
3 389
4 453
5 562
6 9874
7 98745
Run Code Online (Sandbox Code Playgroud)
现在我想用codes2df中的数字来标记df中的数字,codes1对于No column,预期的输出是
ID No Country State City
1 157 IN Telangana Hyderabad
2 346 IN Maharashtra Pune(Bund Garden)
.
.
. …Run Code Online (Sandbox Code Playgroud)