Python Forum
Dropping all rows of multiple columns after the max of one cell
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dropping all rows of multiple columns after the max of one cell
#1
Okay so to be frank I am new to python, and I am trying to interpret some data, this is what I have (below)
so What I am trying to do is make it so that the minimum value for my first column will cause the matplotlib to not plot any values after that specific row (for all three columns, not just area)
Does that make sense?
I thought the pandas pd stuff would do the trick but nope :c Doh Think


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

df = pd.read_csv("C:\\Users\\Owner\\Desktop\\Thunberg,Dametre\\5-29 Data and movies\\New folder (2)\\Data 2.csv", sep=',')
rowmin = df.area.idxmin()
df[:(1 + rowmin)]
fig, ax1 = plt.subplots()
area, pressure, pixel = np.loadtxt ("C:\\Users\\Owner\\Desktop\\Thunberg,Dametre\\5-29 Data and movies\\New folder (2)\\Data 2.csv", delimiter=",", skiprows=1, unpack=True)
plt.plot(area,pressure, label='area/pressure!',color='b')

plt.xlabel('area', color='b')
plt.ylabel('Pressure', color='b')
ax1.tick_params('y', colors='b')
ax2 = ax1.twinx()

ax2.set_ylabel('Intensity (measured by average pixel value)', color='r')

ax2.tick_params('y', colors='r')

ax2.plot(area,pixel, color='r')

plt.title('Kibron Trough Pressure-Area-Intensity Graph')
plt.legend()
plt.show()
Reply


Messages In This Thread
Dropping all rows of multiple columns after the max of one cell - by Thunberd - Jun-01-2018, 06:34 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Merging rows and adding columns based on matching index pythonnewbie78 3 825 Dec-24-2023, 11:51 AM
Last Post: Pedroski55
  Dropping Rows From A Data Frame Based On A Variable JoeDainton123 1 2,229 Aug-03-2020, 02:05 AM
Last Post: scidam
  Filter rows by multiple text conditions in another data frame i.e contains strings an Pan 0 2,162 Jun-09-2020, 06:05 AM
Last Post: Pan
Question Dividing a single column of dataframe into multiple columns based on char length darpInd 2 2,477 Mar-14-2020, 09:19 AM
Last Post: scidam
  read_csv error and rows/columns missing karlito 9 5,344 Nov-11-2019, 06:48 AM
Last Post: karlito
  Drop rows if a set of columns has a value dervast 1 1,989 Sep-12-2019, 04:18 PM
Last Post: sd_0912
  Dropping a column from pandas dataframe marco_ita 6 15,336 Sep-07-2019, 08:36 AM
Last Post: marco_ita
  display graph in columns and rows william888 1 1,858 Jul-02-2019, 10:19 AM
Last Post: dataman
  Grab columns from multiple files, combine into one jon0852 0 2,025 Feb-12-2019, 02:53 AM
Last Post: jon0852
  Slicing String cell by cell Vigneshkumarsakthivel 0 2,403 Sep-02-2018, 05:59 PM
Last Post: Vigneshkumarsakthivel

Forum Jump:

User Panel Messages

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