Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: about Numpy indexing.
Post: RE: about Numpy indexing.

For the first matrix (use the same strategy for the other one) Paul import numpy as np n = 5 M = np.ones( (n,n) ) i = np.arange(1,n) M[i,i-1] = 10*M[i,i-1] print(f'M = {M}')Output:M = [[ 1. 1. 1. ...
paul18fr Data Science 1 37 7 hours ago
    Thread: Help with poorly formatted excel data
Post: RE: Help with poorly formatted excel data

(Jan-13-2022, 12:00 AM)armitron121 Wrote: .... t am stuck on how to transpose it. Any advice? With Pandas transpose ?
paul18fr Data Science 1 90 Jan-13-2022, 07:31 AM
    Thread: Slicing a 2 dimensional array
Post: RE: Slicing a 2 dimensional array

Commas are missing in your list. Here after another 2 ways. Note that in your example you've a single row and that's why flatten has been used. ### from a list MyArray = [[1.6727031, 1.5464988, 1.68...
paul18fr General Coding Help 2 109 Jan-12-2022, 07:18 AM
    Thread: My python code is running very slow on millions of records
Post: RE: My python code is running very slow on million...

What type of data are you dealing with in the original csv file? pure numbers? strings? both? The Appending is costly, and maybe loops can be avoided using vectorisation if data are numbers.
paul18fr General Coding Help 7 274 Dec-27-2021, 12:22 PM
    Thread: How to print each possible permutation in a dictionary that has arrays as values?
Post: RE: How to print each possible permutation in a di...

Maybe with: import itertools as it the_dictionary_list = {'Color': ['Amarillo.png', 'Blanco.png', 'Rojirosado.png', 'Turquesa.png', 'Verde_oscuro.png', 'Zapote.png'], 'Cuerpo...
paul18fr General Coding Help 2 234 Dec-26-2021, 12:37 PM
    Thread: Help needed with merging two CSV files
Post: RE: Help needed with merging two CSV files

You may also use Pandas and Numpy to deal with huge files; just an example here bellow import pandas as pd import numpy as np import os Path=str(os.getcwd()) CsvFile1='data1.csv' CsvFile2='data2.cs...
paul18fr General Coding Help 5 349 Dec-14-2021, 07:34 PM
    Thread: paragraphs in textfile not detected
Post: RE: paragraphs in textfile not detected

Maybe you can use the following code to create a (numpy) array? import pandas as pd MyFile = 'file.txt' MyResults = pd.read_csv(PATH + '/' + MyFile, header = None, delimiter = ' ') MyArray = pd.Data...
paul18fr Data Science 3 338 Dec-04-2021, 10:29 AM
  Star Thread: Program workflow tool
Post: Program workflow tool

All I'm wondering what type of graphical tool I Can use to build workflow of a project (involving modules, dozains of functions, external programs and so on). Never used it so far, but I'm looking for...
paul18fr General Coding Help 0 179 Dec-03-2021, 08:53 AM
    Thread: 2 or more data to be written in a row
Post: RE: 2 or more data to be written in a row

If you're using arrays (1D/2D), you can use numpy.savetxt to have a cvs like file
paul18fr General Coding Help 2 282 Nov-25-2021, 07:24 AM
    Thread: matplotlib x axis range goes over the set range
Post: RE: matplotlib x axis range goes over the set rang...

Here are some changes. For example you can bracket abcissa values or ordinates ones, or you can also implemente Latex formula, and so on. There are many options import matplotlib.pyplot as plt import...
paul18fr General Coding Help 5 517 Nov-21-2021, 08:40 AM
    Thread: Not able to add extra column to the list in the python
Post: RE: Not able to add extra column to the list in th...

The following code works for me import pandas as pd import os PATH=str(os.path.abspath('')) FilesList=['VY6_Row1_report_url.xlsx', 'VY6_Row2_report_url.xlsx'] NumberOfFiles=len(FilesList) # first ...
paul18fr General Coding Help 2 367 Nov-17-2021, 08:20 AM
    Thread: Plot 3 variables
Post: RE: Plot 3 variables

"matplotlib 3d bar plot" on google will help you Nota: comédie Française (don't forget the last "e" **wink** )
paul18fr General Coding Help 3 418 Nov-08-2021, 04:50 PM
    Thread: List comprehension:
Post: List comprehension:

Hi I'm trying to figure out how a list comprehesion works from a "memory" point of view? I mean that append corresponds to a dynamic allocation memory, but what about the list comprehension? In oth...
paul18fr Data Science 1 304 Oct-29-2021, 04:56 PM
    Thread: Write a dictionary with arrays as values into JSON format
Post: RE: Write a dictionary with arrays as values into ...

Thanks for the help; it works perfectly
paul18fr Data Science 3 732 Oct-13-2021, 08:31 PM
    Thread: Write a dictionary with arrays as values into JSON format
Post: Write a dictionary with arrays as values into JSON...

Hi I'm working with dictionaries where values are (numpy) arrays, and I'm trying to figure out how to export these dictionaries in an JSON format, and how to read it afterward. I'm not familiar with...
paul18fr Data Science 3 732 Oct-12-2021, 06:22 AM
    Thread: [solved] Sort list
Post: RE: [solved] Sort list

Thanks to all for their support and advices (as well as for internet links)
paul18fr General Coding Help 5 930 Jul-10-2021, 10:05 AM
    Thread: [solved] Sort list
Post: [solved] Sort list

Hi I've been trapped by names I've been getting in a list; I spent some time in looking in internet to find a way; in the current example, I want that list index 1 correspond to 'Name_2' and not 'Nam...
paul18fr General Coding Help 5 930 Jul-09-2021, 05:21 PM
    Thread: [solved] unexpected character after line continuation character
Post: RE: unexpected character after line continuation c...

Thanks ibreeden for your help; at least a relevant advise
paul18fr General Coding Help 4 906 Jun-21-2021, 04:25 PM
    Thread: [solved] unexpected character after line continuation character
Post: [solved] unexpected character after line continuat...

Hi To higlight reading by adding comments, I'm looking for a way to split function arguments into several lines; nevertheless using backslash I'm facing to an error (I'm still digging on internet in ...
paul18fr General Coding Help 4 906 Jun-21-2021, 01:10 PM
    Thread: [Solved] Using readlines to read data file and sum columns
Post: RE: Using readlines to read data file and sum colu...

I'm not a regex expert, but the following code might help you import re # line = " 0 2 0 -15000 0" line = "50 2 2 -14950 3" Valu...
paul18fr General Coding Help 4 952 Jun-16-2021, 12:13 PM

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020