Categories
Mastering Development

What happens when removing NaN values from a column?

In Pandas, After dropping NaN values from a column, what’s the value stored at the index where the NaN value was removed? I was able to successfully drop NaN values from a column but the shape of the df is intact, yet the size of that particular column changed. 1445 70.0 **1446 NaN** 1447 80.0 […]

Categories
Mastering Development

VBA Last Row errors

I’m using this code, but columns with last row (A,B,K,L) fill in with 0 beyond the defined last row. Additionally, my transaction and type occasionally stop working, but if anyone sees what i’m doing wrong i’d love to learn so i don’t have this issue again. Sub test() Dim lastRow As Long lastRow = Cells(Rows.Count, […]

Categories
Mastering Development

Copy data from excel file with specific column

I was trying few solutions how to read data from file. I’m using for each loop: Dim i As Integer i = 1 Dim data As Variant data = Array("AM", "V", "AA", "K", "C", "D") ‘ // These are columns which have to be copied For Each x In data Workbooks(file).Worksheets("Status").Columns(x).Copy Workbooks("data.xlsx").Worksheets("Sheet1").Columns(i).PasteSpecial Paste:=xlPasteValues i = […]

Categories
Mastering Development

How to create a table using a list of lists

I’m trying to write a file where you have 2 rows, with the first row being numbers and the 2nd row being letters. As an example, I was trying to do this with the alphabet. list1=[‘A’,’B’,’C’,’D’,’E’,’F’,’G’,’H’,’I’,’J’,’K’,’L’,’M’,’N’,’O’,’P’,’Q’,’R’,’S’,’T’,’U’,’V’,’W’,’X’,’Y’,’Z’] list2=list1+list1 abcList = [[],[]] for i in range(len(list2)): i+=1 if i % 5 == 0: if i>=10: abcList[0].append(str(i) + […]

Categories
Mastering Development

Creating a hierarchical dictionary with nested lists or dictionaries from 2 lists

I have 2 lists. The first has number denoting what part of the hierarchy that the value in the other list at the same index belongs. I am trying to get dynamic code that could theoretically go to any number of steps. The first 3 work correctly but when I had more steps to the […]

Categories
User Help Web Apps

Google sheets: How do I convert rows with 45 columns into 15 separate rows, each with 3 columns?

I am working with a google sheet that gets data from an email parser. Each time an email comes in, a single row is created, and fills in these columns: B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, […]

Categories
Mastering Development

Is there a method to convert a letter into it’s index in a tuple in python?

What I mean by the question is if i had: alphabet:["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"] and received an input of "a" I would get back an index of 1, or z to get back an index of 26, from the tuple’s index. I’m wondering if there is an easier way instead of using a dictionary. So like if I […]

Categories
Mastering Development

How does Python’s random.shuffle() alter the value of a list without returning anything and is this something any Python coder can do as well? [duplicate]

I just noticed I wasn’t getting a return from random.shuffle(). I realised this makes sense as you would logically want to work with the original list unless specified otherwise. >>> import string >>> import random >>> letters = list(string.ascii_lowercase) >>> print(letters) [‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’, ‘g’, ‘h’, ‘i’, ‘j’, ‘k’, ‘l’, ‘m’, ‘n’, […]

Categories
Mastering Development

head(data) and data[“rowname”, ] not showing the same results

The following is the first few lines of my script: library(tidyverse) library(caret) # Read and clean up the data ugriz <- read.table( "F:/Users/Jeremy Moss/Dropbox/Astro at VUW/PhD stuff/data_files/optical_data/QSOs_1st_50k.dat-mags.dat") ugriz[ugriz == -999] <- NA fields <- c(‘name’, ‘z’,’delta_z’,’NED_class’,’SDSS_class’,’no_radio’,’radio_max’,’no_UV’, ‘UV_min’, ‘u’, ‘g’, ‘r’, ‘i’, ‘z_mag’, ‘I’, ‘J’, ‘H’, ‘K’, ‘W1’, ‘SPIT_5’, ‘W2’, ‘SPIT_8’, ‘W3’, ‘W4’, ‘NUV’, ‘FUV’) names(ugriz) […]

Categories
Mastering Development

Fill in range with minimum of row range in vba and proceed with next row

I am trying to figure a way to do the following two conditions in excel vba. Add values in increments of 1 to a row range. Each increment should begin with a skipped cell, the next iteration to begin with the empty cell The starting point for the next row should be the minimum of […]