Category : python

I’m trying to generate 500 DataFrames, one for each student. Each DataFrame will be their attendance records. (Bonus) How can I set the name of each DataFrame to be Attendance_i. students DataFrame: student_age = random.randint(4, 13, size = (student_count)) student_sex = random.choice(["male", "female"], size = (student_count)) student_id = list(range(0,student_count)) student_name_local = pd.read_csv(‘Databasestudent_name_local.csv’) student_name_english = pd.read_csv(‘Databasestudent_name_english.csv’) ..

Read more

I have the code listed below to perform a DB truncate – truncate_sql = """ DELETE FROM %s """ cursor.execute(query=truncate_sql%table_name) This code used to delete the rows as expected few months ago. However I see this error now execute() got an unexpected keyword argument ‘query’ The code works fine if I remove "query" cursor.execute(truncate_sql%table_name) I ..

Read more

before i’m so sorry for bad english When the flag is False in loopA, I want the flags of loopB and loopC to be False as well. my code: from multiprocessing import Process import time flag = True flag_time = time.time() def loop_a(): global flag while flag == True: time.sleep(1) print("loop_a") print(time.time() – flag_time) if ..

Read more

I’m trying to use np.isin in my dataframes. Conditions are: df[read]= df1[username]==df2[user] and df1[groupname!=df2[group], "x", " " df[write]= df1[username]==df2[user] and df1[groupname!=df2[group], "z", " " df[execute]= df1[username]==df2[user] and df1[groupname!=df2[group], "q", " " df[read]=df1[username]!=df2[user] and df1[groupname == df2[group], "a", " " df[write]=df1[username]!=df2[user] and df1[groupname == df2[group], "c", " " df[execute]=df1[username]!=df2[user] and df1[groupname == df2[group], "e"," " df[read]=df1[username]!=df2[user] ..

Read more

I have the below dataframe: df = pd.DataFrame({‘a’: [2.85,3.11,3.3,3.275,np.NaN,4.21], ‘b’: [3.65,3.825,3.475,np.NaN,4.10,2.73], ‘c’: [4.3,3.08,np.NaN,2.40, 3.33, 2.48]}, index=pd.date_range(‘2019-01-01′, periods=6, freq=’M’)) I want to calculate the rolling sum with a 3 month frequency for all the columns. I tried using df.groupby(‘column1’)[‘column2′].rolling(3).mean() but that doesn’t seem to work. How should I got about this? Source: Python..

Read more

Here is the data from the xml file, <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Header /> <SOAP-ENV:Body> <ADD_LandIndex_001> <CNTROLAREA> <BSR> <status>ADD</status> <NOUN>LandIndex</NOUN> <REVISION>001</REVISION> </BSR> </CNTROLAREA> <DATAAREA> <LandIndex> <reportId>AMI100031</reportId> <requestKey>R3278458</requestKey> <SubmittedBy>EN4871</SubmittedBy> <submittedOn>2015/01/06 4:20:11 PM</submittedOn> <LandIndex> <agreementdetail> <agreementid>001 4860</agreementid> <agreementtype>NATURAL GAS</agreementtype> <currentstatus> <status>ACTIVE</status> <statuseffectivedate>1965/02/18</statuseffectivedate> <termdate>1965/02/18</termdate> </currentstatus> <designatedrepresentative></designatedrepresentative> </agreementdetail> </LandIndex> </LandIndex> </DATAAREA> </ADD_LandIndex_001> </SOAP-ENV:Body> </SOAP-ENV:Envelope I want to save in a dataframe ..

Read more