Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Plot multiple csv into one graph problem with visualize
Hi everyone,
I really need an help, I created a small code to read 27 file .csv together and plot in the same graph.
In the csv files there is the time( x-axis) and 2 temperatures(y-axis), I don't understand why I get this kind of terrible graph.

import pandas as pd
from glob import glob
import matplotlib.pyplot as plt
import plotly.graph_objects as go

numFiles = 27 #Number of CSV files in your directory
separator = "," #Character that separates each value inside file
fExtension = ".csv" #Extension of the file storing the data

dataframe = sorted(glob('test*.csv'))

pd.concat((pd.read_csv(file).assign(filename = file)
           for file in dataframe), ignore_index  = True)

plt.plot(list(str(dataframe)) )
In this Url link there is the plot
Today I did this
import numpy as np
import glob
import pandas as pd
import csv
import os
import matplotlib.pyplot as plt

path = (r'C:\Users\Alphinity\Desktop\Data visualization\01-07-2019')

all_files = glob.glob(os.path.join(path, 'test*.csv'))

li = []

for filename in all_files:
    df = pd.read_csv(filename, index_col=None, header=0, sep = ';')
df.dropna(inplace = True)
frame = pd.concat(li, axis=0, ignore_index=True)
cols = ['Time Peltier On:', 'T1', 'T2']

for i, row in df.iterrows():
    plt.plot(row['Time Peltier On:'], df['T2'],label ='T2')
    plt.plot(df['Time Peltier On:'], df['T1'],label = 'T1')
    plt.xlabel('Time in Minutes',fontsize=14, fontweight='bold')
    plt.ylabel('Temperature in degree celcius',fontsize=14, fontweight='bold')
    plt.title('[Time Vs Temp]',fontsize=16, fontweight='bold')


But I'm getting always this problem, someone please could help me to find the solution ?
Warning (from warnings module): File "C:\Users\Alphinity\Desktop\Data visualization\01-07-2019\", line 19 frame = pd.concat(li, axis=0, ignore_index=True) FutureWarning: Sorting because non-concatenation axis is not aligned. A future version of pandas will change to not sort by default. To accept the future behavior, pass 'sort=False'. To retain the current behavior and silence the warning, pass 'sort=True'. Traceback (most recent call last): File "C:\Users\Alphinity\Desktop\Data visualization\01-07-2019\", line 27, in <module> plt.plot(row['Time Peltier On:'], df['T2'],label ='T2') File "C:\Program Files (x86)\Python37-32\lib\site-packages\matplotlib\", line 2795, in plot is not None else {}), **kwargs) File "C:\Program Files (x86)\Python37-32\lib\site-packages\matplotlib\axes\", line 1666, in plot lines = [*self._get_lines(*args, data=data, **kwargs)] File "C:\Program Files (x86)\Python37-32\lib\site-packages\matplotlib\axes\", line 225, in __call__ yield from self._plot_args(this, kwargs) File "C:\Program Files (x86)\Python37-32\lib\site-packages\matplotlib\axes\", line 391, in _plot_args x, y = self._xy_from_xy(x, y) File "C:\Program Files (x86)\Python37-32\lib\site-packages\matplotlib\axes\", line 270, in _xy_from_xy "have shapes {} and {}".format(x.shape, y.shape)) ValueError: x and y must have same first dimension, but have shapes (1,) and (891,)
Thank you so much

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Problem with accepting multiple string inputs Ryan_Todd 5 279 Jan-22-2020, 06:12 PM
Last Post: buran
  Visualize Geo Map/Calculate distance zarize 1 239 Dec-05-2019, 08:36 PM
Last Post: Larz60+
  plot multiple employee sales data in a single graph pitanshu 0 296 Oct-24-2019, 01:56 PM
Last Post: pitanshu
  Can't visualize maps using Gmaps mPlummers 0 442 Sep-11-2019, 02:38 PM
Last Post: mPlummers
  Problem with contourf plot and polar projection weihnachtsmo 0 315 Aug-27-2019, 11:42 AM
Last Post: weihnachtsmo
  How to plot multiple scatter plots in seaborn vikola 2 2,458 Jul-14-2019, 10:30 AM
Last Post: vikola
  re.split multiple delimiters problem gw1500se 2 1,007 Jun-24-2019, 02:43 PM
Last Post: gw1500se
  How to plot vertically stacked plot with same x-axis and SriMekala 0 374 Jun-12-2019, 03:31 PM
Last Post: SriMekala
  Graph coloring problem jackrus1010 0 1,902 Oct-20-2018, 10:19 AM
Last Post: jackrus1010
  Multi-processing - problem with running multiple *.py files at the same time Antonio 5 912 Sep-12-2018, 01:08 PM
Last Post: volcano63

Forum Jump:

Users browsing this thread: 1 Guest(s)