0
I have the following code:
import numpy as np
import pandas as pd
import psutil as ps
names = []
for service in ps.win_service_iter():
info = service.as_dict()
listOf = [("Name:%s; " "Display_Name:%s; " "Status:%s " % (info['name'],info['display_name'],info['status']))]
names.append(listOf)
names
And I need the result of this to be inside a DF with the following columns: Name, Name_display, Status.
Can you help me?
I made this script also, where you put the result in DF, however, is unusable filters or LOC, I believe that by the fact that brings the result:
import numpy as np
import pandas as pd
import psutil as ps
names = []
display = []
status = []
for service in ps.win_service_iter():
info = service.as_dict()
listOfNames = [("%s" % (info['name']))]
listOfDisplay = [("%s" % (info['display_name']))]
listOfStatus = [("%s" % (info['status']))]
names.append(listOfNames)
display.append(listOfDisplay)
status.append(listOfStatus)
zippedList = list(zip(names, display, status))
df = pd.DataFrame(zippedList, columns = ['Name' , 'Display', 'Status'])
df
Your question this confused friend, can explain better?
– Clayton Tosatti
I need to put the result of this for a dataframe.. the script returns me like this: ['Name:Ajrouter; Display_name:Alljoyn Router Service; Status:stopped'], ['Name:ALG; Display_name:Application Layer Gateway Service; Status:stopped '],.
– Daymon Rebac
However, when zip the list -- zippedList = list(zip(Names)), I put it in a Dataframe -- df = pd.Dataframe(zippedList, Columns = ['Name', 'Display', 'Status']) it is not usable for example with LOC, does not search for records?
– Daymon Rebac
What does it mean
resultado do for
? The language constructfor
is an iteration loop over a given and a block of actions, these actions may or may not modify or create data, but do not return data. The language construct used to return information is the function, method or property. If the question arises, the variable stores the data.– Augusto Vasques