I have a code that prints out a specific column from an SQL query table. It prints out fine however I would like it to be put into a file and I cannot think of how to do that. Here is what I have: I was thinking of newfile.write( df[[‘PartNumber’]].to_string() ) however that did not work. Thank yo…
Tag: python
Tensorflow – Dense and Convolutional layers connection
I’m new to Deep Learning and I can’t find anywhere how to do the bottleneck in my AE with convolutional and dense layers. The code below is the specific part where I’m struggling: I tried some solutions, like flatten and reshape, but nothing seems to work here. The point is that I need the l…
Not able to perform operations on resulting dataframe after “join” operation in PySpark
Here I have created three dataframes: df,rule_df and query_df. I’ve performed inner join on rule_df and query_df, and stored the resulting dataframe in join_df. However, when I try to simply print the columns of the join_df dataframe, I get the following error- The resultant dataframe is not behaving as…
Reshape 3-d array to 2-d
I want to change my array type as pd.DataFrame but its shape is: I’ve tried to reshape by the following code, but it didn’t work: How can I change its shape? Answer NumPy array dimensions can be reduced using various ways; some are: using np.squeeze: using np.reshape: or with using -1 in np.reshap…
Is there a more efficient way instead of multiple FOR loops and IF statements?
I have the below code snippet: What it intends to do is rename an existing file in case of a correction – for example, I have a file called ‘File Name.xlsx’, but I want to rename it to ‘File Name –CORRECTION1.xlsx’ – it matches the file to each other and renames it. T…
float pointer in ctypes python and pass structure pointer
I’m trying to pass a structure pointer to the API wrapper, Where the struct is containing float pointer member. I’m not sure that how we can pass float pointer value to the structure. /Structure/ /wrapper/ Answer You can either create a c_float instance and initialize with a pointer to that instan…
Pandas / I can’t format the data after Resample.Interpolate
I have these data coming from a csv file I did an interpolate with a 5 min period Here is the result Then I would like to keep only 2 digits so I did a test on the first column : But nothing has changed as a result Answer Did you save the result?
Is there any function to get multiple timeseries with .get and create a dataframe in Pandas?
I get multiple time series data in series format with datetimeindex, which I want to resample and convert to a dataframe with multiple columns with each column representing each time series. I am using separate functions to create the dataframe, for example, .get(), .resample(), pd.concat(). Since it is not f…
How to join linked models with foreign key?
I’m coming from Java and new to python / django. So may be my question is silly … I have one class Parent which contains an association with a class Child. Parent refers to its ‘Childs’ through the related name ‘children’. At Run time it works well, but at design time, it i…
Select rows of a data frame in a loop based on list of indexes
I have one data frame & two (or multiple) lists of indexes: I want to create a loop where I can select the rows of data. for each iteration, I use one list. so for 1st iteration data has the rows shown in idx1 0,2,4. how I can do that ? This is a simplified example, in my actual code,