1

I need to use Python and Angular JS to send a CSV file from python to web page and display it accordingly.

I've got 2 CSV files with fields as

CSV1

Country code,Telecom,Latency

919618, India Private Mobile,0.008800

919619, India Private Mobile,0.008800

919620, India Private Mobile,0.008800

CSV2

Country code,Telecom,Latency

919802, India Private Mobile,0.008400

919803, India Private Mobile,0.008400

919620, India Private Mobile,0.008400

The web page should display as

Country code,Telecom,Latency

919618, India Private Mobile,0.008800

919619, India Private Mobile,0.008800

919802, India Private Mobile,0.008400

919803, India Private Mobile,0.008400

919620,India Private Mobile,0.008400,0.008800

(The last line contain two values cause the CSV file contains 919620 commons in both)

So now I'm new to Angular JS and Flask, just guide me how to start?

started with this

import pandas as pd
import numpy as np


dfa = pd.read_csv('rate4.csv', names=['Country Code', 'SP', 'Rate']);
dfb = pd.read_csv('rate3.csv', names=['Country Code', 'SP', 'Rate']);
Rahi.Shah
  • 1,305
  • 11
  • 20
Yash Kumar Atri
  • 786
  • 1
  • 9
  • 27

1 Answers1

2

You can use for output DataFrame use concat and groupby by columns Country code and Telecom with join column Latency:

df = pd.concat([df1, df2]) \
       .groupby(['Country code','Telecom'])['Latency'] \
       .apply(lambda x: ','.join(x.astype(str))) \
       .reset_index()
print (df)
   Country code               Telecom        Latency
0        919618  India Private Mobile         0.0088
1        919619  India Private Mobile         0.0088
2        919620  India Private Mobile  0.0088,0.0084
3        919802  India Private Mobile         0.0084
4        919803  India Private Mobile         0.0084
jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252
  • Traceback (most recent call last): File "C:/Users/Yash Kumar Atri/PycharmProjects/untitled/test/prettyprint.py", line 12, in df = pd.concat([dfa, dfb]).groupby(['Country Code','Telecom'])['Latency'].join(lambda x: ','.join(x.astype(str))) File "C:\Program Files\Python36\lib\site-packages\pandas\core\groupby.py", line 551, in __getattr__ (type(self).__name__, attr)) AttributeError: 'SeriesGroupBy' object has no attribute 'join' – Yash Kumar Atri Jun 20 '17 at 06:42
  • hey can you suggest me something for displaying whole data at once cause it display 28 233 GHANA FIXED 0.0088 29 234 NIGERIA FIXED 0.0088 ... ... ... ... 20431 91612794 India Fixed 0.0084 20432 91674791 India Fixed 0.0084 cause it display triple dots in between – Yash Kumar Atri Jun 20 '17 at 06:47
  • Unfortunately I have no idea, never do something in `Flask`. Maybe help some another post like [this](https://stackoverflow.com/q/22180993/2901002) or [this](https://stackoverflow.com/a/39403732/2901002) – jezrael Jun 20 '17 at 06:49