Skip to content

Tag: python

Parse text with uncertain number of fields

I have a file (~50,000 lines) text.txt as below, which contains some gene info from five individuals (AB, BB, CA, DD, GG). The t in the file is a tab seperator. There are also a lot of info that are not useful in the file, and I would like to clean it up. So What I need is to extract

Add one day for certain time

I want to update my date column with certain times because some of the dates are not correct. For some reason, they key in the date with time between 00:00 and 7:30 with the day before. For example: Which supposes to be like this: I know I can update all of dates with this code. But I have no idea

Is it possible to import a folder as a module?

I have a library I’m working on that is intended to be imported like import raycekar as rk and have its individual files referenced as rk.unit.whatever. This is the directory structure: From within main.py, if I from raycekar import ui, I can access ui. If I want to import raycekar as rk, rk.ui raises a…

How do I put this into one line? [closed]

Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 months ago. Improve this question So I have this basic code. How could I make it into line? without in…

Pandas multiple comparison on a single row

My source data looks like this: I need to compare Second column with Third, Fourth Column with Fifth Column, Sixth with Seventh. Column names can change. So I have to consider the column positions and my first column with always has column name as id. so if atleast one of comparisons (‘1_src1’ vs …

Writing data to multiple folders in Python

I am trying to write A in multiple folders, namely, 1,2,3,4,5 with file name A.txt. But I am getting an error. How do I fix it? The error is Answer There appears to be a dearth of answers explaining what the actual problem is among the possible duplicates on this site, so here goes. csv.csvwriter.writerow exp…