Python Forum
Pandas: how to split one row of data to multiple rows and columns in Python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pandas: how to split one row of data to multiple rows and columns in Python
#4
(Feb-20-2021, 03:44 PM)eddywinch82 Wrote: Hi GerardMoussendo,

Could you post the Full Code ?

It would help me, with coming up with a solution for you.

Regards

Eddie Winch

Here is my entire code:

import numpy as np
import pylab
import matplotlib.pyplot as plt
import pandas as pd


data = np.memmap("F:\data.pcm", dtype='h', mode='r')
print("VALUES:", data)
pylab.plot(data)
pylab.show()
np.save("data_signal.npy", data)
l = np.load("data_signal.npy")
# print(l)
s = np.arange(len(l)).reshape(-1,5)
print(s)
pylab.plot(s)
pylab.show()
Now, it seems like
Quote:s = np.arange(len(l)).reshape(-1,5)
can work right? But how can I save the s reshaped data? I am having difficulty saving it in .npy
After reshaped, I have this result below:
Quote:[[ 0 1 2 3 4]
[ 5 6 7 8 9]
[ 10 11 12 13 14]
...
[1583985 1583986 1583987 1583988 1583989]
[1583990 1583991 1583992 1583993 1583994]
[1583995 1583996 1583997 1583998 1583999]]
Reply


Messages In This Thread
RE: Pandas: how to split one row of data to multiple rows and columns in Python - by GerardMoussendo - Feb-21-2021, 05:51 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How is pandas modifying all rows in an assignment - python-newbie question markm74 1 703 Nov-28-2023, 10:36 PM
Last Post: deanhystad
  python convert multiple files to multiple lists MCL169 6 1,556 Nov-25-2023, 05:31 AM
Last Post: Iqratech
  Better python library to create ER Diagram by using pandas data frames as tables klllmmm 0 1,131 Oct-19-2023, 01:01 PM
Last Post: klllmmm
  Using pyodbc&pandas to load a Table data to df tester_V 3 821 Sep-09-2023, 08:55 PM
Last Post: tester_V
  how do you style data frame that has empty rows. gsaray101 0 531 Sep-08-2023, 05:20 PM
Last Post: gsaray101
  How to check multiple columns value within range SamLiu 2 1,151 Mar-13-2023, 09:32 AM
Last Post: SamLiu
  Converting a json file to a dataframe with rows and columns eyavuz21 13 4,476 Jan-29-2023, 03:59 PM
Last Post: eyavuz21
  (Python) Pulling data from UA Google Analytics with more than 100k rows into csv. Stockers 0 1,231 Dec-19-2022, 11:11 PM
Last Post: Stockers
  Extracting Data into Columns using pdfplumber arvin 17 5,569 Dec-17-2022, 11:59 AM
Last Post: arvin
  How to properly format rows and columns in excel data from parsed .txt blocks jh67 7 1,880 Dec-12-2022, 08:22 PM
Last Post: jh67

Forum Jump:

User Panel Messages

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