0

I have two CSV files both files when I read an print the files the output is like:

tweet_id                    id        
312498024964313000          3.430000e+17     
312278640362659000          3.430000e+17

The id and tweet_id both columns are in the same format and required sample output is :

tweet_id              id        
3.124980e+17          3.430660e+17 
3.122790e+17          3.430880e+17

Please tell me how to solve this problem. I later use both of these columns to merge two CSV files.

rafaelc
  • 57,686
  • 15
  • 58
  • 82
Asma Ahmad
  • 408
  • 1
  • 3
  • 15

2 Answers2

0

You can set the float_format with pd.set_option. Just change both columns to float first:

pd.set_option('display.float_format', '{:.6g}'.format)

df.astype(float)
     tweet_id  id        
0 3.12498e+17    3.43e+17
1 3.12279e+17    3.43e+17

Note: Your expected output for id doesn't seem to match your input. The above result is based on the sample input provided.

andrew_reece
  • 20,390
  • 3
  • 33
  • 58
0

Hey i think you have to combine them into 1 data frame. You can tell because your printed statement on the bottom starts at a 0 index as well.

Use the .join method to join them, then try print them:

data_frame1 = pd.DataFrame(data=['a','b', 'c'], columns=['Alphabit'])
data_frame2 = pd.DataFrame(data=[1,2,3], columns = ['Numbers'])
data_frame1.join(data_frame2)

edit: sorry I think i misinterpreted your original question.

docbrown
  • 17
  • 4
  • The problem is when I try to join them it returns me null values. As id and tweet_id locations are not the same. – Asma Ahmad Aug 04 '18 at 15:25