Skip to content
Advertisement

Tag: python-3.x

Python RegEx check string

im trying to set correct version on output. I have this possible strings: 0.0.4.1 # 1. 7.51.4.1 # 2. 0.1.4.1 # 3. and i need to check, if the “0.” is on the start (to set output without 0. or 0.0.) Output 1. will have just “4.1”, 2. gonna stay the same and 3. will be 1.4.1 Im trying to

Wrong result with regular expressions

Any idea why the regular expression below cuts the ‘fl’ part of the sentence ? This is the result I get : Answer You’re replacing all non-alphabetical characters with whitespace. In your code, the ‘fl’ is actually fl – a single unicode (non-AZ) character, so it is being removed, along with the punctuation.

Python – Trying to print each line that has a string value that matches the index provided

Now I’m still pretty new to python and programming in general, but I know I’ve gone a bit of a roundabout way this entire program. But here is what I have and what I want if anyone can help. Begins by reading a text file e.g. ADF101,Lecture,Monday,08:00,10:00,Jenolan,J10112,Joe Blo ADF101,Tutorial,Thursday,10:00,11:00,Jenolan,J10115,Cat Blue ALM204,Lecture,Monday,09:00,11:00,Tarana,T05201,Kim Toll Then I make empty lists and append them

Match two dataframes and fill the column value in pandas

I have two excel file. I have to match them based on particular column and fill the other column. I explain you in the example. Example: 2 excel files: monitered call.xlsx In this excel 2 sheets are there, 1. print add 2. digital digital C2D.xlsx single sheet is there Sheet1 monitered calls.xlsx: digital C2D.xlsx I have to match Caller Number

python convert timedelta to meaningful string such as “1 hours”

I want to convert a python timedelta object to an easy to read meaningful string for example: any ideas how to do that? Thanks Answer Actually timedelta class, provides you days, seconds, microseconds property directly. But in order to get “hours” and “minutes” you can do some simple calculations yourself. Divide seconds by 60 to get minutes, by 3600 to

How to create n-dimensional sparse tensor? (pytorch)

I want to initialize tensor to sparse tensor. When tensor’s dimensional is 2, I can use torch.nn.init.sparse(tensor, sparsity=0.1) Result But when tensor dimensions > 2, this function isn’t work. Result I need this because I want to use it to initialize the convolution weights. torch.nn.init.sparse_() function’s def is below How could I make n-dimensional sparse tensor? Is there a way

Advertisement