[Solved] Print and write values in a file greater and lesser than 10 and make a plot of it by using Python


Rhea

I’m not sure I understand what are trying to accomplish there, therefore I’ll try to help you going through some basic stuff:

a) Do you already have your data on a DataFrame format? Or it is in some form of tabular data such as a csv or Excel file?

Dataframe = Two-dimensional size-mutable, potentially heterogeneous tabular data structure with labeled axes (rows and columns).

Anyways you will have to import pandas to read or manipulate this file. Then you can transform it into a DataFrame using one of Pandas reading functions, such as pandas.read_csv or pandas.read_excel.

import pandas as pd
# if your data is in a dictionary
df = pd.DataFrame(data=d)
# csv
df = pd.read_csv('file name and path') 

b) Then you can slice through it using pandas, and create new DataFrames

output1 = df.loc[df['Numbers'] > 10]
output2 = df.loc[df['Numbers'] < 10]

c) The most basic way to plot is using the pandas method plot on your new DataFrame (you can get a lot fancier than that using matplotlib or seaborn). Although you should probably think about what kind of information you want to visualize, which is not clear to me.

out1.plot()
#histogram
out2.hist()

d) You can save your new dataframes using pandas as well. Here is an example of a CSV file

df.to_csv(path_or_buf=None, sep=', ', na_rep='', float_format=None, columns=None, header=True, index=True, index_label=None)

I hope I could shed some light into your doubts 😉 .

solved Print and write values in a file greater and lesser than 10 and make a plot of it by using Python