let’s say I have a room and a dataframe(/timeseries) df, which has minutely timestamps in one column df[‘timestamp’] and entries and exits for each minute in the other two columns df[‘entries’] & df[‘exits’] (those may be 0). Now I want to create a fourth column, which tells me how much people there are inside the ..
Category : python
I have dataframe that looks like this: State State_theft_sum Model_1 Model_year_1 Alabama 2154 Chevrolet Pickup (Full Size) 2005.0 Alaska 547 Chevrolet Pickup (Full Size) 2003.0 Arizona 5270 Honda Accord 1997.0 DF goes on and on, so changing values separately isn’t the way. I though i might be able to replace them using result of loop ..
I have a fits file whose ‘x’ values are in channels. I would like to convert them(x values) from channels to frequency in GHz. What the code does is it basically reads in the fits file and does gaussian curve fitting to the data. Dimension of the file and format respectively: (256, 256, 591) float32 ..
My ping command doesn’t work in a cog but works in my main.py file. Here’s the code for the cog: import discord from discord.ext import commands class Misc(commands.Cog): def __init__(self, bot): self.bot = bot @commands.Cog.listener() async def on_ready(self): print(‘Misc cog loadedn—–‘) @commands.command() async def ping(self, ctx): await ctx.send(f’pong!n{round(bot.latency * 1000)}ms’) def setup(bot): bot.add_cog(Misc(bot)) When I ..
I created code to drop some rows according to certain condition : df3 = df_clean[(df_clean[‘group’] == ‘treatment’) & (df_clean[‘landing_page’] != ‘new_page’)].index df2 = df_clean.drop(df3 , inplace=True) df2.head() but I got this error: AttributeError: ‘NoneType’ object has no attribute ‘head’ Source: Python..
I have a binary file with text in it. I need to grab the hex bytes of the string, and convert them to readable text. I’m using Python 3. The encoding appears to be UTF-8, but I’ve been having some trouble decoding some specific strings. You see, some strings appear to have unicode code points ..
I am checking wether one of two conditions applies and only one. My question is if there is a way to have a single if statement to do this: if x == True: if y == False: do_something() elif x == False: if y == True: do_something() Ideally similar to how and and or work ..
I have two lists of 5 elements. I want to use itertools or a python code returns a list of 5 elements that consist of all permutations of the list, by only swapping elements of the two lists that have the same index. For example, if A = [1,2,3,4,5] and B = [a,b,c,d,e], I want ..
I have 2 python files. One file has all of the functions, the other file has a function which calls functions from the first file. Here is a simplified version of what I have. file1.py def one(): print("Hello World") def two(): print("Salutations Earth") def three(): print("Greetings World") file2.py import file1 function_id = input("Which function would ..
I met a weird JSON response and need to save it to a excel, tried pandas but it doesn’t work in the expected way(or maybe I’m using it wrong, new to python), now I’m trying to use xlwt to format it, but the only params I got in JSON response is "height, left, top, width": ..
Recent Comments