python-3.x

Finding start time and end time in a column

99封情书 提交于 2021-02-10 07:11:12
问题 I have a data set that has employees clocking in and out. It looks like this (note two entries per employee): Employee Date Time Emp1 1/1/16 06:00 Emp1 1/1/16 13:00 Emp2 1/1/16 09:00 Emp2 1/1/16 17:00 Emp3 1/1/16 11:00 Emp3 1/1/16 18:00 I want to get the data to look like this: Employee Date Start End Emp1 1/1/16 06:00 13:00 Emp2 1/1/16 09:00 17:00 Emp3 1/1/16 11:00 18:00 I would like to get it into a data frame format so that I can do some calculations. I currently have tried df['start'] =

Finding start time and end time in a column

天大地大妈咪最大 提交于 2021-02-10 07:06:12
问题 I have a data set that has employees clocking in and out. It looks like this (note two entries per employee): Employee Date Time Emp1 1/1/16 06:00 Emp1 1/1/16 13:00 Emp2 1/1/16 09:00 Emp2 1/1/16 17:00 Emp3 1/1/16 11:00 Emp3 1/1/16 18:00 I want to get the data to look like this: Employee Date Start End Emp1 1/1/16 06:00 13:00 Emp2 1/1/16 09:00 17:00 Emp3 1/1/16 11:00 18:00 I would like to get it into a data frame format so that I can do some calculations. I currently have tried df['start'] =

How to determine what is imported via `from m import *`?

好久不见. 提交于 2021-02-10 06:48:47
问题 I'm doing some patching of import statements, and I need to know exactly what members are imported by from m import * . The documentation seems to indicate that when __all__ is absent, all members will be imported that do not begin with an underscore. Is this exactly correct under all circumstances? I know that inspect.getmembers() , dir() , and m.__dict__ all have slightly different logic, so I'm not completely sure which (if any) will provide the same list as import * . 回答1: Let's take a

hide console with executing python script

你离开我真会死。 提交于 2021-02-10 06:48:34
问题 I am trying to compile my python script built in python 3 using pyqt5 module on windows 10 using pyinstaller which hides the windows while running. To compile my script I executed following command: pyinstaller --onefile --icon=app.ico --clean --noconsole app.py But the executable I got didn't worked so again I compiled my script by following command: pyinstaller --onefile -w --icon=app.ico app.py Still the output executable is not working if --console/-w/--windowed argument is used. How can

hide console with executing python script

╄→гoц情女王★ 提交于 2021-02-10 06:48:11
问题 I am trying to compile my python script built in python 3 using pyqt5 module on windows 10 using pyinstaller which hides the windows while running. To compile my script I executed following command: pyinstaller --onefile --icon=app.ico --clean --noconsole app.py But the executable I got didn't worked so again I compiled my script by following command: pyinstaller --onefile -w --icon=app.ico app.py Still the output executable is not working if --console/-w/--windowed argument is used. How can

Cosine Similarity rows in a dataframe of pandas

て烟熏妆下的殇ゞ 提交于 2021-02-10 06:45:09
问题 I have a CSV file which have content as belows and I want to calculate the cosine similarity from one the remaining ID in the CSV file. I have load it into a dataframe of pandas as follows: old_df['Vector']=old_df.apply(lambda row: np.array(np.matrix(row.Vector)).ravel(), axis = 1) l=[] for a in old_df['Vector']: l.append(a) A=np.array(l) similarities = cosine_similarity(A) The output looks fine. However, i do not know how to find which the GUID (or ID)similar to other GUID (or ID), and I

How do I make my monster move randomly in my game

淺唱寂寞╮ 提交于 2021-02-10 06:38:08
问题 I'm fairly new to programming and via a tutorial created a maze game which I've added too. It's all working well but I'd now like to add a monster or 2 to make it more of a challenge! I just want to keep it simple and have the monster randomly moving around the maze. I have created a monster but despite trying different things it won't move. I suspect I need to add something to the main loop but I don't know what. The code is below. Any help is appreciated! import os import random import

How to use beautifulsoup to check if a string exists

南笙酒味 提交于 2021-02-10 06:33:55
问题 Hi I am trying to write a program that scraps a URL and if the scrap data contains a particular string do something how can i use beautiful soup to achieve this import requests from bs4 import BeautifulSoup data = requests.get('https://www.google.com',verify=False) soup= BeautifulSoup(data.string,'html.parser') for inp in soup.find_all('input'): if inp == "Google Search": print ("found") else: print ("nothing") 回答1: Your inp is a html object. You must use get_text() function import requests

PIL change color channel intensity

你离开我真会死。 提交于 2021-02-10 06:28:26
问题 I want to make a color picker, which recolors a png texture while preserving transparency in python3. I only want the brighter parts of the image to be recolored, but also keep the gradient. The only option the I could think of was to adjust the color channel intensity, however I did not find anything like that in the PIL docs. How do I change the color channel intensity? My PNG texture is loaded in ARGB mode and can be found >>here<<. Original Image: 回答1: I dreamt up an approach for this:

Writing a Python UI for a seperate program with tkinter. The stop button for this program basically freezes the UI and continues with the script

落爺英雄遲暮 提交于 2021-02-10 06:25:29
问题 Here is what I coded... import tkinter as tk import subprocess import sys import time import os import tkinter.font as font from tkinter.ttk import * app = tk.Tk() app.geometry("400x400") app.configure(bg='gray') photo = tk.PhotoImage(file=r"C:\Users\ex\ex_button_active.png") myFont = font.Font(family='Helvetica', size=20, weight='normal') tk.Label(app, text='EX', bg='gray', font=( 'Verdana', 15)).pack(side=tk.TOP, pady=10) app.iconbitmap(r'C:\Users\ex\ex_icon.ico') start = time.time() cmd =