I am trying to sort data in a CSV file using sort function in Pandas using the following code. I have 229 rows in original file. But the output of sorting is 245 rows, because some of the data in a field were printed in the next row and some of the rows do not have any value.
sample=pd.read_csv("sample.csv" , encoding='latin-1', skipinitialspace=True)
sample_sorted = sample.sort_values(by = ['rating'])
sample_sorted.to_csv("sample_sorted.csv")
I think, this problem happened because in some cells data was entered by generating new lines. For example this is the content of a cell in original file. When I sort the original file, the second line was printed in a new row and 3 rows left empty between first and second line.
"Side effects are way to extreme.
E-mail me if you have experianced the same things."
Any suggestion? Thanks !
print(sample.shape)?