Skip to main content

Posts

Can't Implement Cython File into Python File and create Executable using Pyinstaller

I wanted to obfuscate ( Protect ) my Python Code so it couldn't be easily readed by others ( users ).I'm making a program for Public Usage, but I want my Source Code to be hidden.It would be an offline Program. I saw many texts on many Websites about Cython, so I started Investigating its behaviour.Few Websites connected Cython with Sentinel LDK Envelope, so I tried using them both, but there wasn't any success with Sentinel LDK Envelope because of the Program's nature.I created Python Extension ( .pyd ) and C File with Cython of my Python File.I tried making it work in various ways.I tried compiling Cython C File Code to Executable using Visual Studio 2022 and gcc, but that wasn't successful because of the Errors that were in that Code ( Couldn't import "Python.h" and few other Modules, I tried linking them directly and few other things, but that wasn't so successful ).After that, I tried to create an Executable from Python Extension.I imported P

Python - creating lists from a '.fasta' file containing the proteome of an organism

I want to create two lists using data from a '.fasta' file containing around 14.000 proteins and their sequence in FASTA-format. This is the proteome of an organism. One list will contain the identifiers, which is each line in the file starting with '>'. The other list needs to contain the full sequence from a protein as one element in the list. This is for me, a beginner, decently difficult considering the sequence of one protein is also longer than one line in the file, and every protein varies in length. Here's a toy example (these are the first three proteins form the proteome): tr|A0A087QGI9|A0A087QGI9_APTFO Neuroblast differentiation-associated protein AHNAK (Fragment) OS=Aptenodytes forsteri OX=9233 GN=AS27_15363 PE=4 SV=1 GDVDVSVPKLEGDLKGPEVDIKGPKVDIEAPDVDIHGPEGKIKIPKFKMPKFGLSGLKGE GPEVDVNLPEADVALSGPKVDVTLPDLDVEGPEGKLKGPKFKKPDVQFNVPKISMPEIDL NLKGPKLKADLDPSLPKIEGELKGPEVDIKGPKVDIEAPDVDFHGPEGKLKMPKFKMPKF GASGFKAEGPEVDVSVPKGELDVSGPKLDSEGAGFQIEGPEGKFKGPQFK

regex extract digit + word [duplicate]

I want to extract the exact value+unit from the 8 rows below. But my code is not working properly. For example, my code extracts in row 4 "1000 2 ounce" instead of only "2 ounce". Same issue with row 5 and 6. includes chalkboard labels, marker & measuring cup capacity s | 135.2 ounce capacity 33% thicker - 12 glass spice - 3 cubic inch capacity nolopau 1.53 gallon capacity lon glass jar, [1000 2 ounce capacity compostable condiment souffluide bagasse bia cordon bleu inc 900712 8.5 ounce capacity porcelain bekith 15 9 liter capacity glass jars, echtpower bento box, 1.5 milliliter lunch box with handle aislor plastic straining 0.50 gallon capacity lon pitcher, dishwasher Outcome for each row: 153.2 ounce 3 cubic inch 1.53 gallon 2 ounce 8.5 ounce 9 liter 1.5 milliliter 0.50 gallon I tried: def extract_c(df): pattern = (\d+.\d+\s*ounce|\d+.\d+\s*cubic\s*inch|\d+.\d+\s*gallon|\d+.\d+\s*liter|\d+.\d+\s*milliliter)' return df.str.extract(pattern)

Encoding Multiple Categorical Data with Python using sklearn.preprocessing.LabelEncoder() takes too much processing time on 2D array inputs

Consider for some reason I am trying to encode a feature. Let's say my feature name is title . For the title feature, for one record I might have different words: title = 'Apple', 'Jobs'. Let me illustrate: ID title 0 ['Apple', 'Jobs'] 1 ['Wozniak'] 2 ['Apple', 'Wozniak'] 3 ['Jobs', 'Wozniak'] As you could see my unique values are : unique = ['Apple','Jobs','Wozniak'] And previously I was using label encoder as: from sklearn.preprocessing import LabelEncoder le.fit(unique) for i in df['title'].index: df['title'][i] = le.transform(df['title'][i]) And I used to get something like: ID title 0 [782, 256] 1 [331] 2 [782, 331] 3 [256, 331] which was exactly what I wanted; yet, this takes too much time because I have too many values to iterate and encode. Thus, I am looking for an algorithm that is smarter and preferably with a

ValueError: Expected 2D array, got 1D array instead

I'm a beginner in Data Science and I'm currently working on building a model for the IBM Employee Attrition Dataset. How do I get around this error? # LogisticRegression from sklearn.linear_model import LogisticRegression from sklearn import metrics from sklearn.model_selection import train_test_split #Copy the DataFrame df1 = df.copy() #Convert categorical variables to numeric dummy_df = pd.get_dummies(df1, columns=["Attrition", "BusinessTravel", "Department", "EducationField", "Gender", "JobRole", "OverTime", "MaritalStatus"], drop_first = True) dummy_df = pd.concat([df1, dummy_df], axis=1) dummy_df = dummy_df.drop(["Attrition", "BusinessTravel", "Department", "EducationField", "Gender", "JobRole", "OverTime", "MaritalStatus"], axis=

Webpack, insert output in already existing file

I am new to webpack and trying to output in an already existing base file my final bundle. I have a function main() and want to print there my bundle Has anyone ever had my same problem? May yoou help me out? Thanks in advance! Googling, i found out this question but didn't help out Is it possible to add some defined lines of code to webpack's bundle in the dist folder Via Active questions tagged javascript - Stack Overflow https://ift.tt/ADdXZl2

How to animate a number ticking up in HTML [closed]

Edit: I figured it out myself. If this question was re-opened, I could provide my own answer. I'm trying to have a number "tick up" when it changes, in a similar fashion to Twitter's like/retweet/comment counters and Discord's reaction counter. I haven't found any information about this on the web (mainly because I don't know what it's formally called). Edit: I forgot to include the code, here it is: The counter element itself: <span id="counter" class="counter">0</span> The CSS for the element: .counter { display: inline-block; height: 15px; font-size: 15px; overflow-y: hidden; } The JavaScript for changing the counter: function changeCounter(id, num) { var _x = document.getElementById(id); _x.innerHTML += _x.innerHTML + "<br>" + num; _x.style.transition = "0.2s"; setTimeout(function () { _x.style.marginTop = "-15px"; setTimeout